Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!ames!elroy.jpl.nasa.gov!jato!lwall From: lwall@jato.Jpl.Nasa.Gov (Larry Wall) Newsgroups: comp.unix.questions Subject: Re: Friendly UMASK wanted Message-ID: <2738@jato.Jpl.Nasa.Gov> Date: 2 Feb 90 19:55:17 GMT References: <2069@syma.sussex.ac.uk> <5265@star.cs.vu.nl> Reply-To: lwall@jato.Jpl.Nasa.Gov (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 66 In article <5265@star.cs.vu.nl> maart@cs.vu.nl (Maarten Litmaath) writes: : In article <2069@syma.sussex.ac.uk>, : andy@syma.sussex.ac.uk (Andy Clews) writes: : \... : \ umask go-rw : : Csh: : alias mask 'set tmp="`/full/path/of/mask \!*`"; eval $tmp' : : Sh (supporting shell functions): : : mask() : { : tmp="`/full/path/of/mask $*`" : eval $tmp : } : : ...mask being the following shell script hack (Perl, Randal?). : [123 line shell script from purgatory deleted] Well, I'm not Randal, but here's the same thing in perl, 40 lines: #!/usr/bin/perl ($name = $0) =~ s!.*/!!; $umask = umask; $USAGE = <>= 1; } $sym = "$_=" . $sym; } print "echo $sym\n"; } elsif ($arg =~ /^\d+$/) { # change numerically print "umask $arg\n"; } else { # change symbolically (cheat: let chmod do it) $tmp="/tmp/umask$$"; open(TMP,">$tmp") || die "$name: Can't create $tmp: $!\n"; chmod ~$umask & 0777, $tmp; ($err = `chmod $ARGV[0] $tmp 2>&1`) =~ s/chmod/$name/; die $err if $err; ($dev,$ino,$mode) = stat TMP; unlink $tmp; printf "umask %o\n", ~$mode & 0777; } Larry Wall lwall@jpl-devvax.jpl.nasa.gov