>> Example (if possible): >> -------------------------- >> $ chmod 777 -t 30 myfile.txt >> # Grants full access to "myfile.txt" for 30 minutes >> # After 30 minutes, permissions revert to their previous state
>$ chmod-t() { local m=$(stat -c %a "$2"); chmod "$1" "$2"; sleep ${3}m; chmod >$m "$2"; } >$ chmod-t 777 myfile.txt 30 Except that, of course, no one would ever do it like that. The whole point is that you want the command to return immediately, but have a background process/thread running to chmod it back. Which means two things: 1) It probably has to be done at the C level, not the shell level, in order to have an aesthetically pleasing implementation. Yes, I know you can use "&" at the end of the command line to "background" it, but that is ugly (for a variety of reasons). 2) It'll (obviously) never get done in mainline coreutils "chmod", but there's nothing stopping OP from doing his own version to do it. Note also: Although the idea seems odd, and most people's intuitive reaction is/was "WTF?", I actually get where OP is coming from and wish that there was some more direct way to accomplish this. But Unix being Unix, there just isn't. I would imagine that OP (or an associate) got bitten by this once and therefore wishes there were some built-in way to avert it in future. The problem is that unless it was builtin to the "chmod" command, people won't use it - that's the "human factor" that has been ignore so far in the responses. P.S. Oh, and there is no bug here. This thread belongs in "coreutils" (not "bug-coreutils"). ================================================================================= Please do not send me replies to my posts on the list. I always read the replies via the web archive, so CC'ing to me is unnecessary. When responding to my posts, please try to refrain from giving bureaucratic answers. If you have nothing useful to say, then just click Next and go on.