in reply to Re: perl file permissions
in thread perl file permissions

you cannot set a umask in a way that will toggle the x flag

I s'pose it depends on what you mean by toggle. Only programs like compilers set execute permission on in the first place. The umask can only remove permissions that the original utility sets, it can't add them.

Replies are listed 'Best First'.
Re^3: perl file permissions
by KurtSchwind (Chaplain) on Dec 05, 2007 at 17:44 UTC

    I'm not sure what you mean by that. You can set ANY file in unix to execute (assuming you have the perms to do so.) You can make an mp3 file 'executable' if you want to. You certainly don't need a compiler.

    umask [-p] [-S] [mode] The user file-creation mask is set to mode. If mode begins with a dig +it, it is interpreted as an octal number; otherwise it is interpreted as a symbolic mode mask + similar to that accepted by chmod(1). If mode is omitted, the current value of the mask is printe +d. The -S option causes the mask to be printed in symbolic form; the default output is an octal + number. If the -p option is supplied, and mode is omitted, the output is in a form that +may be reused as input. The return status is 0 if the mode was successfully changed or if no m +ode argument was supplied, and false otherwise.

    --
    I used to drive a Heisenbergmobile, but every time I looked at the speedometer, I got lost.
      He's saying that umask masks bits, it doesn't cause new files to be created with extra bits set by default.

      Most general-purpose apps create general text files with a generic 666 mode, and the system masks with the user's active umask value (e.g., 770 or 700), resulting in a 660 or 600 mode. A compiler might create the final executable (e.g., a.out) with a 777 mode as the point of the executable is to execute it. Since vi doesn't know that the point of a .pl file is to execute it, it doesn't go the extra mile.

      (To enhance the OP's question, it does kind of sound cool if vi/emacs/jot/whatever were to make mode choices based on the extension and/or the shebang line, and to "do the right thing" automagically. Making a wrapper script for your favorite editor is a reasonable workaround; making a cronjob or a new version of Unix or bash is not.)

      Anyone can write an app to create all files at 777, which would include the executable bit whether it made sense or not. He's not saying compilers are magical in this regard, just that it seems natural in that case.

      --
      [ e d @ h a l l e y . c c ]