Bug 206809 - [patch] Add Octal Number Support for install -f
Summary: [patch] Add Octal Number Support for install -f
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 10.2-RELEASE
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-bugs mailing list
Keywords: patch
Depends on:
Reported: 2016-02-01 00:19 UTC by A.J. Kehoe IV (Nanoman)
Modified: 2016-05-17 19:23 UTC (History)
1 user (show)

See Also:

patch to add octal number support for install -f (430 bytes, patch)
2016-02-01 00:19 UTC, A.J. Kehoe IV (Nanoman)
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description A.J. Kehoe IV (Nanoman) 2016-02-01 00:19:02 UTC
Created attachment 166372 [details]
patch to add octal number support for install -f

Let's say you have a file that has file flags, and you need to use install(1) to install a copy of it that doesn't have file flags.  After reading the manuals of install(1) and chflags(1), you try this:

# install -f 0 /path/to/foo /path/to/bar
install: 0: invalid flag

It seems that install -f doesn't support octal numbers.  There isn't a single keyword that clears all file flags, so to use only install, you'd have to do this:

# install -f noarch,dump,noopaque,nosappnd,noschg,nosunlnk,nouappnd,nouarch,nouchg,nouhidden,nouoffline,nourdonly,nousparse,nousystem,noureparse,nouunlnk /path/to/foo /path/to/bar

A workaround would be to use both install and chflags:

# install /path/to/foo /path/to/bar
# chflags 0 /path/to/bar

I've attached a patch for /head/usr.bin/xinstall/xinstall.c.  This patch adds octal number support for install -f.
Comment 1 Jilles Tjoelker freebsd_committer 2016-05-16 13:18:34 UTC
This change is not necessary for this purpose, since install(1) flags work differently from chflags(1). With chflags(1), you specify changes to the flags but with install(1), if you specify -f, it overrides all the flags. Therefore, you can use

  install -f '' /path/to/foo /path/to/bar

If you want to copy flags using stat -f %Sf, you will unfortunately need a special case for no flags, as stat will write '-' which install (and chflags) will not accept.

Something in me does not like proliferating octal numbers further.
Comment 2 A.J. Kehoe IV (Nanoman) 2016-05-17 19:23:52 UTC
Here's what install(1)'s manual shows for -f:

"Specify the target's file flags; see chflags(1) for a list of possible flags and their meanings."

I interpret the first part of this sentence as meaning that the target's file flags will be set to whatever has been defined by -f, not that they will be adjusted like what you'd get by using chflags(1).  If I'm interpreting this incorrectly, then maybe this should be reworded to avoid confusion.

When I see chflags(1) for a list of possible flags, the manual shows me that "flags are specified as an octal number or a comma separated list of keywords".  I interpret this as meaning that install(1) should support either octal numbers or keywords, but looking at /head/usr.bin/xinstall/xinstall.c, I see support for keywords, and no support for octal numbers.

If the intention is to phase out usage of octal numbers, then maybe a better solution would be to change install(1)'s manual entry for its -f option to something like this:

"Specify the target's file flags; see the keywords section of chflags(1) for a list of possible flags and their meanings.  Use -f '' to specify no flags for the target."