From: Mark Wooding Date: Sun, 5 Apr 2015 09:53:38 +0000 (+0100) Subject: with-umask: New tool. DWISOTT. X-Git-Tag: 1.3.2~1 X-Git-Url: https://git.distorted.org.uk/~mdw/misc/commitdiff_plain/3dd40cc8d8a8075b4a6f5c3ffbf43d194748665e with-umask: New tool. DWISOTT. --- diff --git a/Makefile.am b/Makefile.am index 86027e8..2e70051 100644 --- a/Makefile.am +++ b/Makefile.am @@ -178,6 +178,9 @@ hush.1: hush.1.in Makefile $(SUBST) $(srcdir)/hush.1.in >$@.new $(SUBSTITUTIONS) && \ mv $@.new $@ +dist_bin_SCRIPTS += with-umask +dist_man_MANS += with-umask.1 + ## bash scripts. if HAVE_BASH diff --git a/debian/control b/debian/control index 612e813..b518388 100644 --- a/debian/control +++ b/debian/control @@ -114,6 +114,11 @@ Architecture: all Section: utils Description: Captures stdin in a temporary file and runs a command. +Package: with-umask +Architecture: all +Section: utils +Description: Runs a command with a given umask. + Package: create Architecture: all Section: utils diff --git a/debian/inst b/debian/inst index e704da3..5e26960 100644 --- a/debian/inst +++ b/debian/inst @@ -50,3 +50,5 @@ x86-model x86-model /usr/bin x86-model.1 x86-model /usr/share/man/man1 hush hush /usr/bin hush.1 hush /usr/share/man/man1 +with-umask with-umask /usr/bin +with-umask.1 with-umask /usr/share/man/man1 diff --git a/with-umask b/with-umask new file mode 100755 index 0000000..644cffb --- /dev/null +++ b/with-umask @@ -0,0 +1,12 @@ +#! /bin/sh -e + +prog=${0##*/} +usage="usage: $prog MASK CMD [ARGS ...]" +case $1,$# in + -h,*) echo "$usage"; exit 0 ;; + -*) echo >&2 "unknown option \`$1'"; exit 1 ;; + ,0 | *,1) echo >&2 "$usage"; exit 1 ;; +esac +umask $1 +shift +exec "$@" diff --git a/with-umask.1 b/with-umask.1 new file mode 100644 index 0000000..c264331 --- /dev/null +++ b/with-umask.1 @@ -0,0 +1,52 @@ +.de VS +.sp 1 +.RS +.nf +.ft B +.. +.de VE +.ft R +.fi +.RE +.sp 1 +.. +.TH with-umask 1 "5 April 2015" "Edgeware tools" +.SH NAME +with-umask \- run a command with a particular umask set +.SH SYNOPSIS +.B with-umask +.I mode +.I command +.RI [ arguments ...] +.SH DESCRIPTION +The +.B with-umask +program sets its umask to +.I mode +and then executes +.I command +with the given +.IR arguments . +.PP +The +.I mode +may be either a literal mask written in octal, where set bits correspond +to mode bits to be forced clear when creating files, or a symbolic mode +in +.BR chmod (1) +style listing the mode bits to be preserved. (Other forms may be +acceptable: +.B with-umask +is currently a shell script, and uses +.BR /bin/sh 's +.B umask +built-in to do its work.) +.PP +Command line options: +.TP +.B "\-h" +Show very brief help, and exit. +.SH BUGS +None known. +.SH AUTHOR +Mark Wooding