0

I'm trying to use umask -S to show the current mask in symbolic form (per man umask on my system, which gives me the page BASH_BUILTINS(1)). But umask doesn't seem to behave as the manpage claims:

user$ umask
22
user$ umask -S
umask: Improper mask.
user$ umask -p
umask: Improper mask.
user$ which umask
umask: shell built-in command.

I'm running this in csh on RHEL 6.9. Something like umask 022 works fine. Why would the behavior differ from the manpage?

  • 1
    Related questions are https://unix.stackexchange.com/questions/167004/ , https://unix.stackexchange.com/questions/460567/ , and https://unix.stackexchange.com/questions/68876/ . – JdeBP Nov 01 '18 at 15:10

1 Answers1

3

Since umask changes the internal state of the shell, it has to be a shell builtin.

POSIX shells umask builtin have a -S option as that's a POSIX requirement, but csh's doesn't. Your umask man page documents the umask builtin of bash, not that of csh. Check the csh man page for the documentation of its umask builtin.

There's no good reason why you'd want to use csh in this century, especially on a GNU/Linux system, but if you have to, you can always do:

sh -c 'umask -S'

to report a symbolic form of that umask.

That would report the umask of the the child process executing sh, but since the umask is inherited upon fork and preserved across exec, that should be the same as csh's umask.

In any case, that returned umask won't be useful to csh, as csh's umask builtin doesn't support symbolic forms.

  • "There's no good reason why you'd want to use [x] in this century [...]" Hm I don't have a good reason. Maybe only a mediocre one: "Because that's what this system administrator has decided to use, and I'm not that administrator." ;) Being new to csh I'm surprised man [builtin] would not give me info on the builtin in the context of my current shell, but that's not relevant to the question. Thanks for the clarification. I can see man csh does not give any options, as you say. – Kevin Kruse Nov 01 '18 at 14:29
  • 1
    man is not a builtin command of csh (or any shell for that matters). There's only one man command, so it can only give you one man page for a given word. Some systems may have different sections for the documentation of different shell builtins, I don't know of any though. Try man -a umask on your system to see if any other man page for umask comes up and note the section they're in (note that many languages, beside shells have a umask function) – Stéphane Chazelas Nov 01 '18 at 14:33