From bca250b0b2a1df4ceb939b71a269f71501fda024 Mon Sep 17 00:00:00 2001
From: Laurent Bercot
Date: Thu, 30 Jul 2026 03:21:52 +0000
Subject: Prepare for 2.10.0.0; remove pedantic posix; support loopwhilex -x
""
---
.gitignore | 5 +-
NEWS | 11 ++
configure | 13 --
doc/cd.html | 60 +++++++
doc/execline-cd.html | 55 -------
doc/execline-umask.html | 51 ------
doc/index.html | 10 +-
doc/loopwhilex.html | 10 +-
doc/posix-cd.html | 66 --------
doc/posix-umask.html | 74 ---------
doc/umask.html | 61 ++++++++
doc/upgrade.html | 10 ++
package/configure-snippets/configure_case_lines | 2 -
.../configure-snippets/configure_generate_configh | 4 -
package/configure-snippets/configure_generate_make | 5 -
package/configure-snippets/configure_help_options | 1 -
package/configure-snippets/configure_init_vars | 1 -
package/deps.mak | 19 +--
package/info | 2 +-
package/modes | 6 +-
package/targets.mak | 11 +-
src/execline/cd.c | 17 ++
src/execline/deps-exe/cd | 1 +
src/execline/deps-exe/execline-cd | 1 -
src/execline/deps-exe/execline-umask | 1 -
src/execline/deps-exe/posix-cd | 1 -
src/execline/deps-exe/posix-umask | 1 -
src/execline/deps-exe/umask | 1 +
src/execline/emptyenv.c | 36 ++---
src/execline/execline-cd.c | 17 --
src/execline/execline-umask.c | 19 ---
src/execline/loopwhilex.c | 102 +++++++-----
src/execline/posix-cd.c | 160 -------------------
src/execline/posix-umask.c | 174 ---------------------
src/execline/posix-umask.txt | 37 -----
src/execline/redirfd.c | 94 +++++------
src/execline/umask.c | 158 +++++++++++++++++++
src/execline/umask.txt | 37 +++++
src/execline/wait.c | 45 +++---
tools/gen-multicall.sh | 20 +--
40 files changed, 525 insertions(+), 874 deletions(-)
create mode 100644 doc/cd.html
delete mode 100644 doc/execline-cd.html
delete mode 100644 doc/execline-umask.html
delete mode 100644 doc/posix-cd.html
delete mode 100644 doc/posix-umask.html
create mode 100644 doc/umask.html
create mode 100644 src/execline/cd.c
create mode 100644 src/execline/deps-exe/cd
delete mode 100644 src/execline/deps-exe/execline-cd
delete mode 100644 src/execline/deps-exe/execline-umask
delete mode 100644 src/execline/deps-exe/posix-cd
delete mode 100644 src/execline/deps-exe/posix-umask
create mode 100644 src/execline/deps-exe/umask
delete mode 100644 src/execline/execline-cd.c
delete mode 100644 src/execline/execline-umask.c
delete mode 100644 src/execline/posix-cd.c
delete mode 100644 src/execline/posix-umask.c
delete mode 100644 src/execline/posix-umask.txt
create mode 100644 src/execline/umask.c
create mode 100644 src/execline/umask.txt
diff --git a/.gitignore b/.gitignore
index 5118c05..dff0c8d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,6 +10,7 @@
/background
/backtick
/case
+/cd
/define
/dollarat
/elgetopt
@@ -20,8 +21,6 @@
/envfile
/exec
/execlineb
-/execline-cd
-/execline-umask
/exit
/export
/export-array
@@ -49,8 +48,6 @@
/multisubstitute
/pipeline
/piperw
-/posix-cd
-/posix-umask
/redirfd
/runblock
/shift
diff --git a/NEWS b/NEWS
index a42f9a7..a69510f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,16 @@
Changelog for execline.
+In 2.10.0.0
+-----------
+
+ - --enable-pedantic-posix option removed.
+ - execline-cd is now cd.
+ - posix-umask is now umask.
+ - execline-umask and posix-cd removed.
+ - loopwhilex -n option removed.
+ - loopwhilex -x "" now loops forever.
+
+
In 2.9.9.2
----------
diff --git a/configure b/configure
index 323ce07..d6ed5c4 100755
--- a/configure
+++ b/configure
@@ -51,7 +51,6 @@ Optional features:
--enable-slashpackage[=ROOT] assume /package installation at ROOT [disabled]
--enable-absolute-paths hardcode absolute BINDIR/foobar paths in binaries [disabled]
--enable-nsss use the nsss library for user information [disabled]
- --enable-pedantic-posix use pedantically POSIX-compatible binaries [disabled]
--enable-multicall build a multicall binary [disabled]
EOF
@@ -176,7 +175,6 @@ vpathd=''
build=
shebangisdefault=true
usensss=false
-pposix=false
multicall=false
for arg ; do
@@ -220,8 +218,6 @@ for arg ; do
--shebangdir=*) shebangisdefault=false ; shebangdir=${arg#*=} ;;
--enable-nsss|--enable-nsss=yes) usensss=true ;;
--disable-nsss|--enable-nsss=no) usensss=false ;;
- --enable-pedantic-posix|--enable-pedantic-posix=yes) pposix=true ;;
- --disable-pedantic-posix|--enable-pedantic-posix=no) pposix=false ;;
--enable-multicall|--enable-multicall=yes) multicall=true ;;
--disable-multicall|--enable-multicall=no) multicall=false ;;
--enable-*|--disable-*|--with-*|--without-*|--*dir=*) ;;
@@ -543,11 +539,6 @@ else
echo "LIBNSSS :="
echo "MAYBEPTHREAD_LIB :="
fi
-if $pposix ; then
- echo "PEDANTIC_POSIX := 1"
-else
- echo "PEDANTIC_POSIX :="
-fi
if $multicall ; then
echo "MULTICALL := 1"
else
@@ -586,10 +577,6 @@ echo "#define ${package_macro_name}_LIBEXECPREFIX \"$libexecdir/\""
echo "#define ${package_macro_name}_SYSCONFPREFIX \"$sysconfdir/\""
echo "#define ${package_macro_name}_SHEBANGPREFIX \"$shebangdir/\""
echo
-echo "#undef ${package_macro_name}_PEDANTIC_POSIX"
-if $pposix ; then
-echo "#define ${package_macro_name}_PEDANTIC_POSIX"
-fi
echo
echo "#endif"
exec 1>&3 3>&-
diff --git a/doc/cd.html b/doc/cd.html
new file mode 100644
index 0000000..fbd6687
--- /dev/null
+++ b/doc/cd.html
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+ execline: the cd command
+
+
+
+
+
+
+
+execline
+Software
+skarnet.org
+
+
+ The cd program
+
+
+cd changes the current working directory to a
+given directory, then executes a program.
+
+
+ Interface
+
+
+ cd dir prog...
+
+
+
+cd performs a
+chdir()
+system call on dir, then execs into prog....
+
+
+ Notes
+
+
+ - This cd program will never be invoked by a shell, unless its full path
+is explicitly given to the shell command line. So it is perfectly acceptable and valid
+to have a cd binary in the filesystem. No confusion will be possible: shells
+will invoke their builtin
+cd
+utility, and execline scripts will invoke the cd binary.
+ - Previous versions of POSIX also required a conformant cd binary to exist
+in the filesystem, for no reason at all. So, in previous execline versions,
+a posix-cd binary was present, and cd could be installed as a symlink
+to it when execline was configured with the --enable-pedantic-posix option.
+This allowed distributions to make execline binaries, including cd, available
+in PATH, while strictly conforming to POSIX. This requirement has now been relaxed by
+POSIX, so the needlessly complex posix-cd program was replaced with this
+simpler cd, that can now be made available in PATH without breaking strict
+conformance.
+
+
+
+
diff --git a/doc/execline-cd.html b/doc/execline-cd.html
deleted file mode 100644
index 6d55142..0000000
--- a/doc/execline-cd.html
+++ /dev/null
@@ -1,55 +0,0 @@
-
-
-
-
-
-
- execline: the execline-cd command
-
-
-
-
-
-
-
-execline
-Software
-skarnet.org
-
-
- The execline-cd program
-
-
-execline-cd changes the current working directory to a
-given directory, then executes a program.
-
-
- Interface
-
-
- execline-cd dir prog...
-
-
-
-execline-cd performs a
-chdir()
-system call on dir, then execs into prog....
-
-
- Notes
-
-
- - By default, execline-cd can also be invoked as cd:
-there is a cd program which is a symbolic link to execline-cd.
- - When execline has been configured with the --enable-pedantic-posix
-option, the cd binary is a symbolic link to the
-posix-cd binary instead, so a cd command
-in an execline script will invoke posix-cd instead
-of execline-cd.
- - Existing scripts that call cd will keep working no matter the
-chosen configuration.
-
-
-
-
-
diff --git a/doc/execline-umask.html b/doc/execline-umask.html
deleted file mode 100644
index e0aa76f..0000000
--- a/doc/execline-umask.html
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-
-
-
-
- execline: the execline-umask command
-
-
-
-
-
-
-
-execline
-Software
-skarnet.org
-
-
- The execline-umask program
-
-
-execline-umask sets the umask (file creation mask),
-then executes a program.
-
-
- Interface
-
-
- execline-umask mask prog...
-
-
-
-execline-umask sets the current umask to mask,
-then execs into prog....
-
-
- Notes
-
-
-- By default, at execline installation time, a umask
-symbolic link is created, pointing to execline-umask.
-
- When execline has been configured with the --enable-pedantic-posix
-option, the umask symbolic link points to the
-posix-umask binary instead.
- - Existing execline scripts calling umask will keep working
-no matter the chosen configuration.
-
-
-
-
diff --git a/doc/index.html b/doc/index.html
index e57e4af..075fcf9 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -78,8 +78,8 @@ want nsswitch-like functionality:
Download
- - The current released version of execline is 2.9.9.2.
-You can access its checksum here.
+ - The current released version of execline is 2.10.0.0.
+You can access its checksum here.
- Alternatively, you can checkout a copy of the
execline
git repository:
@@ -128,10 +128,8 @@ the previous versions of execline and the current one.
(Process state control)
- loopwhilex [ -n ] [ -o okcodes | -x breakcodes ] prog...
+ loopwhilex [ -o okcodes | -x breakcodes ] prog...
@@ -48,9 +48,11 @@ looping as long as prog exits with one of the codes in
- -x breakcodes : like the previous
option, but with inverted meaning - the listed exit codes are codes
that will break the loop and exit, and the unlisted exit codes will keep
-the loop running.
- - -n : negate the test. This option is now redundant,
-and may disappear soon.
+the loop running. -x "" will make loopwhilex loop
+forever.
+ - If both -o and -x options are given -o
+has priority and the list given by -x is ignored. If none of
+these options is given, -o 0 is the default.
Notes
diff --git a/doc/posix-cd.html b/doc/posix-cd.html
deleted file mode 100644
index 6419d0a..0000000
--- a/doc/posix-cd.html
+++ /dev/null
@@ -1,66 +0,0 @@
-
-
-
-
-
-
- execline: the posix-cd command
-
-
-
-
-
-
-
-execline
-Software
-skarnet.org
-
-
- The posix-cd program
-
-
-posix-cd changes the current working directory to a
-given directory, then executes a program.
-
-
- Interface
-
-
- posix-cd [ -L | -P ] dir prog...
-
-
-
-posix-cd changes the current working directory to dir
-according to the
-POSIX
-specification for a cd external utility. Then, if prog... is
-not empty, it execs into it.
-
-
- Notes
-
-
- - When execline has been configured
-with the --enable-pedantic-posix option, the cd
-command is a symbolic link to it. So scripts calling cd
-will use posix-cd. When this configuration option has not
-been given, cd is a symbolic link to
-execline-cd.
- - posix-cd fully conforms to the
-POSIX
-specification. When prog... is not empty, the behaviour of a
-cd utility is not specified by POSIX, so posix-cd extends
-the spec to be actually useful and usable in an execline program with the same
-interface as the regular execline cd command.
- - Nobody ever executes or needs the external version (i.e. not a shell
-builtin) of the POSIX cd command. Compared to execline's regular cd
-binary, execline-cd, posix-cd is
-uselessly bloated and slow. The only reason it exists is that some
-distributions refuse to package execline correctly unless it is strictly
-POSIX-compliant; the --enable-pedantic-posix configure option is
-there to satisfy their requirements.
-
-
-
-
diff --git a/doc/posix-umask.html b/doc/posix-umask.html
deleted file mode 100644
index f3ab05f..0000000
--- a/doc/posix-umask.html
+++ /dev/null
@@ -1,74 +0,0 @@
-
-
-
-
-
-
- execline: the posix-umask command
-
-
-
-
-
-
-
-execline
-Software
-skarnet.org
-
-
- The posix-umask program
-
-
-posix-umask changes its file mode creation mask, then executes a program.
-
-
- Interface
-
-
- posix-umask [ -S ] [ mask ] [ prog... ]
-
-
-
-When called with no argument, posix-umask prints the value of the
-file mode creation mask of the invoking process, then exits 0.
-
-
-
- When called with a mask argument, posix-umask changes
-its file mode creation mask; then, if prog... is not empty, it execs
-into it.
-
-
-
- posix-umask interprets mask as specified by the
-POSIX
-specification for a umask external utility.
-
-
- Notes
-
-
- - When execline has been configured
-with the --enable-pedantic-posix option, the umask
-command is a symbolic link to it. So scripts calling umask
-will use posix-umask. When this configuration option has not
-been given, umask is a symbolic link to
-execline-umask.
- - posix-umask fully conforms to the
-POSIX
-specification. When prog... is not empty, the behaviour of a
-umask utility is not specified by POSIX, so posix-umask extends
-the spec to be actually useful and usable in an execline program with the same
-interface as the regular execline umask command.
- - Nobody ever executes or needs the external version (i.e. not a shell
-builtin) of the POSIX umask command. Compared to execline's regular umask
-binary, execline-umask, posix-umask is
-uselessly bloated and slow. The only reason it exists is that some
-distributions refuse to package execline correctly unless it is strictly
-POSIX-compliant; the --enable-pedantic-posix configure option is
-there to satisfy their requirements.
-
-
-
-
diff --git a/doc/umask.html b/doc/umask.html
new file mode 100644
index 0000000..d837130
--- /dev/null
+++ b/doc/umask.html
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+ execline: the umask command
+
+
+
+
+
+
+
+execline
+Software
+skarnet.org
+
+
+ The umask program
+
+
+umask changes its file mode creation mask, then executes a program.
+Alternatively, it can print the current mask.
+
+
+ Interface
+
+
+ umask [ -S ] [ mask ] [ prog... ]
+
+
+
+When called with no argument, umask prints the value of the
+file mode creation mask of the invoking process, then exits 0.
+
+
+
+ When called with a mask argument, umask changes
+its file mode creation mask; then, if prog... is not empty, it execs
+into it.
+
+
+
+ umask interprets mask as specified by the
+POSIX
+specification for a umask external utility.
+
+
+ Notes
+
+
+ - umask fully conforms to the
+POSIX
+specification. When prog... is not empty, the behaviour of a
+umask utility is not specified by POSIX, so umask extends
+the spec to be actually useful and usable in an execline program.
+
+
+
+
diff --git a/doc/upgrade.html b/doc/upgrade.html
index e814afa..31de4b9 100644
--- a/doc/upgrade.html
+++ b/doc/upgrade.html
@@ -19,6 +19,16 @@
What has changed in execline
+ in 2.10.0.0
+
+
+ - The --enable-pedantic-posix configuration option has
+been removed, due to POSIX relaxing requirements on intrinsic utilities.
+ - The cd binary is now what was previously execline-cd.
+ - The umask binary is now what was previously posix-umask,
+(without locale support, not that it had much to start with)
+
+
in 2.9.9.2
diff --git a/package/configure-snippets/configure_case_lines b/package/configure-snippets/configure_case_lines
index e193af8..30bde83 100644
--- a/package/configure-snippets/configure_case_lines
+++ b/package/configure-snippets/configure_case_lines
@@ -1,7 +1,5 @@
--shebangdir=*) shebangisdefault=false ; shebangdir=${arg#*=} ;;
--enable-nsss|--enable-nsss=yes) usensss=true ;;
--disable-nsss|--enable-nsss=no) usensss=false ;;
- --enable-pedantic-posix|--enable-pedantic-posix=yes) pposix=true ;;
- --disable-pedantic-posix|--enable-pedantic-posix=no) pposix=false ;;
--enable-multicall|--enable-multicall=yes) multicall=true ;;
--disable-multicall|--enable-multicall=no) multicall=false ;;
diff --git a/package/configure-snippets/configure_generate_configh b/package/configure-snippets/configure_generate_configh
index ef276bd..cd338aa 100644
--- a/package/configure-snippets/configure_generate_configh
+++ b/package/configure-snippets/configure_generate_configh
@@ -1,6 +1,2 @@
echo "#define ${package_macro_name}_SHEBANGPREFIX \"$shebangdir/\""
echo
-echo "#undef ${package_macro_name}_PEDANTIC_POSIX"
-if $pposix ; then
-echo "#define ${package_macro_name}_PEDANTIC_POSIX"
-fi
diff --git a/package/configure-snippets/configure_generate_make b/package/configure-snippets/configure_generate_make
index dbf93ff..3590ea5 100644
--- a/package/configure-snippets/configure_generate_make
+++ b/package/configure-snippets/configure_generate_make
@@ -5,11 +5,6 @@ else
echo "LIBNSSS :="
echo "MAYBEPTHREAD_LIB :="
fi
-if $pposix ; then
- echo "PEDANTIC_POSIX := 1"
-else
- echo "PEDANTIC_POSIX :="
-fi
if $multicall ; then
echo "MULTICALL := 1"
else
diff --git a/package/configure-snippets/configure_help_options b/package/configure-snippets/configure_help_options
index c6fd410..0874fae 100644
--- a/package/configure-snippets/configure_help_options
+++ b/package/configure-snippets/configure_help_options
@@ -1,4 +1,3 @@
--enable-nsss use the nsss library for user information [disabled]
- --enable-pedantic-posix use pedantically POSIX-compatible binaries [disabled]
--enable-multicall build a multicall binary [disabled]
diff --git a/package/configure-snippets/configure_init_vars b/package/configure-snippets/configure_init_vars
index 91a8590..ad92eac 100644
--- a/package/configure-snippets/configure_init_vars
+++ b/package/configure-snippets/configure_init_vars
@@ -1,4 +1,3 @@
shebangisdefault=true
usensss=false
-pposix=false
multicall=false
diff --git a/package/deps.mak b/package/deps.mak
index 44338fd..94192c2 100644
--- a/package/deps.mak
+++ b/package/deps.mak
@@ -5,6 +5,7 @@
src/execline/background.o src/execline/background.lo: src/execline/background.c src/include/execline/execline.h
src/execline/backtick.o src/execline/backtick.lo: src/execline/backtick.c src/include/execline/execline.h
src/execline/case.o src/execline/case.lo: src/execline/case.c src/include/execline/execline.h
+src/execline/cd.o src/execline/cd.lo: src/execline/cd.c
src/execline/define.o src/execline/define.lo: src/execline/define.c src/include-local/exlsn.h
src/execline/dollarat.o src/execline/dollarat.lo: src/execline/dollarat.c
src/execline/elgetopt.o src/execline/elgetopt.lo: src/execline/elgetopt.c src/include/execline/execline.h
@@ -14,8 +15,6 @@ src/execline/eltest.o src/execline/eltest.lo: src/execline/eltest.c
src/execline/emptyenv.o src/execline/emptyenv.lo: src/execline/emptyenv.c src/include/execline/execline.h
src/execline/envfile.o src/execline/envfile.lo: src/execline/envfile.c
src/execline/exec.o src/execline/exec.lo: src/execline/exec.c
-src/execline/execline-cd.o src/execline/execline-cd.lo: src/execline/execline-cd.c
-src/execline/execline-umask.o src/execline/execline-umask.lo: src/execline/execline-umask.c
src/execline/execlineb.o src/execline/execlineb.lo: src/execline/execlineb.c src/include/execline/execline.h src/include-local/exlsn.h
src/execline/exit.o src/execline/exit.lo: src/execline/exit.c
src/execline/export-array.o src/execline/export-array.lo: src/execline/export-array.c src/include/execline/execline.h
@@ -43,13 +42,12 @@ src/execline/multidefine.o src/execline/multidefine.lo: src/execline/multidefine
src/execline/multisubstitute.o src/execline/multisubstitute.lo: src/execline/multisubstitute.c src/include/execline/execline.h src/include-local/exlsn.h
src/execline/pipeline.o src/execline/pipeline.lo: src/execline/pipeline.c src/include/execline/execline.h
src/execline/piperw.o src/execline/piperw.lo: src/execline/piperw.c
-src/execline/posix-cd.o src/execline/posix-cd.lo: src/execline/posix-cd.c
-src/execline/posix-umask.o src/execline/posix-umask.lo: src/execline/posix-umask.c
src/execline/redirfd.o src/execline/redirfd.lo: src/execline/redirfd.c src/include/execline/execline.h
src/execline/runblock.o src/execline/runblock.lo: src/execline/runblock.c src/include/execline/execline.h
src/execline/shift.o src/execline/shift.lo: src/execline/shift.c src/include/execline/execline.h
src/execline/trap.o src/execline/trap.lo: src/execline/trap.c src/include/execline/execline.h
src/execline/tryexec.o src/execline/tryexec.lo: src/execline/tryexec.c src/include/execline/execline.h
+src/execline/umask.o src/execline/umask.lo: src/execline/umask.c
src/execline/unexport.o src/execline/unexport.lo: src/execline/unexport.c
src/execline/wait.o src/execline/wait.lo: src/execline/wait.c src/include/execline/config.h src/include/execline/execline.h
src/execline/withstdinas.o src/execline/withstdinas.lo: src/execline/withstdinas.c src/include/execline/execline.h
@@ -82,6 +80,7 @@ src/libexecline/exlsn_free.o src/libexecline/exlsn_free.lo: src/libexecline/exls
src/libexecline/exlsn_importas.o src/libexecline/exlsn_importas.lo: src/libexecline/exlsn_importas.c src/include/execline/execline.h src/include-local/exlsn.h
src/libexecline/exlsn_main.o src/libexecline/exlsn_main.lo: src/libexecline/exlsn_main.c src/include/execline/execline.h src/include-local/exlsn.h
src/libexecline/exlsn_multidefine.o src/libexecline/exlsn_multidefine.lo: src/libexecline/exlsn_multidefine.c src/include/execline/execline.h src/include-local/exlsn.h
+src/multicall/execline.o src/multicall/execline.lo: src/multicall/execline.c src/include/execline/config.h src/include/execline/execline.h src/include-local/exlsn.h
background: EXTRA_LIBS := ${SPAWN_LIB}
background: src/execline/background.o ${LIBEXECLINE} -lskarnet
@@ -89,6 +88,8 @@ backtick: EXTRA_LIBS := ${SPAWN_LIB}
backtick: src/execline/backtick.o ${LIBEXECLINE} -lskarnet
case: EXTRA_LIBS :=
case: src/execline/case.o ${LIBEXECLINE} -lskarnet
+cd: EXTRA_LIBS :=
+cd: src/execline/cd.o -lskarnet
define: EXTRA_LIBS :=
define: src/execline/define.o ${LIBEXECLINE} -lskarnet
dollarat: EXTRA_LIBS :=
@@ -107,10 +108,6 @@ envfile: EXTRA_LIBS :=
envfile: src/execline/envfile.o -lskarnet
exec: EXTRA_LIBS :=
exec: src/execline/exec.o -lskarnet
-execline-cd: EXTRA_LIBS :=
-execline-cd: src/execline/execline-cd.o -lskarnet
-execline-umask: EXTRA_LIBS :=
-execline-umask: src/execline/execline-umask.o -lskarnet
execlineb: EXTRA_LIBS :=
execlineb: src/execline/execlineb.o ${LIBEXECLINE} -lskarnet
exit: EXTRA_LIBS :=
@@ -165,10 +162,6 @@ pipeline: EXTRA_LIBS := ${SPAWN_LIB}
pipeline: src/execline/pipeline.o ${LIBEXECLINE} -lskarnet
piperw: EXTRA_LIBS :=
piperw: src/execline/piperw.o -lskarnet
-posix-cd: EXTRA_LIBS :=
-posix-cd: src/execline/posix-cd.o -lskarnet
-posix-umask: EXTRA_LIBS :=
-posix-umask: src/execline/posix-umask.o -lskarnet
redirfd: EXTRA_LIBS :=
redirfd: src/execline/redirfd.o ${LIBEXECLINE} -lskarnet
runblock: EXTRA_LIBS :=
@@ -179,6 +172,8 @@ trap: EXTRA_LIBS := ${SPAWN_LIB}
trap: src/execline/trap.o ${LIBEXECLINE} -lskarnet
tryexec: EXTRA_LIBS :=
tryexec: src/execline/tryexec.o ${LIBEXECLINE} -lskarnet
+umask: EXTRA_LIBS :=
+umask: src/execline/umask.o -lskarnet
unexport: EXTRA_LIBS :=
unexport: src/execline/unexport.o -lskarnet
wait: EXTRA_LIBS :=
diff --git a/package/info b/package/info
index 518ffa8..76d9d2c 100644
--- a/package/info
+++ b/package/info
@@ -1,4 +1,4 @@
package=execline
-version=2.9.9.2
+version=2.10.0.0
category=admin
package_macro_name=EXECLINE
diff --git a/package/modes b/package/modes
index b07e67a..025602e 100644
--- a/package/modes
+++ b/package/modes
@@ -1,14 +1,13 @@
background 0755
backtick 0755
case 0755
+cd 0755
define 0755
dollarat 0755
elgetopt 0755
elgetpositionals 0755
elglob 0755
eltest 0755
-execline-cd 0755
-execline-umask 0755
emptyenv 0755
envfile 0755
exec 0755
@@ -39,13 +38,12 @@ multidefine 0755
multisubstitute 0755
piperw 0755
pipeline 0755
-posix-cd 0755
-posix-umask 0755
redirfd 0755
runblock 0755
shift 0755
trap 0755
tryexec 0755
+umask 0755
unexport 0755
wait 0755
withstdinas 0755
diff --git a/package/targets.mak b/package/targets.mak
index 8fc04a1..a255280 100644
--- a/package/targets.mak
+++ b/package/targets.mak
@@ -6,7 +6,7 @@ ifeq ($(MULTICALL),1)
BIN_TARGETS := execline
CONTENTS := $(notdir $(wildcard src/execline/deps-exe/*))
-BIN_SYMLINKS := cd umask $(CONTENTS)
+BIN_SYMLINKS := $(CONTENTS)
EXTRA_TARGETS += src/multicall/execline.c
define symlink_definition
@@ -22,14 +22,5 @@ src/multicall/execline.o: src/multicall/execline.c src/include/execline/config.h
else
BIN_TARGETS := $(notdir $(wildcard src/execline/deps-exe/*))
-BIN_SYMLINKS := cd umask
-
-ifeq ($(PEDANTIC_POSIX),1)
-SYMLINK_TARGET_cd := posix-cd
-SYMLINK_TARGET_umask := posix-umask
-else
-SYMLINK_TARGET_cd := execline-cd
-SYMLINK_TARGET_umask := execline-umask
-endif
endif
diff --git a/src/execline/cd.c b/src/execline/cd.c
new file mode 100644
index 0000000..734c375
--- /dev/null
+++ b/src/execline/cd.c
@@ -0,0 +1,17 @@
+/* ISC license. */
+
+#include
+
+#include
+#include
+
+#define USAGE "cd path prog..."
+
+int main (int argc, char const *const *argv)
+{
+ PROG = "cd" ;
+ if (argc < 3) strerr_dieusage(100, USAGE) ;
+ if (chdir(argv[1]) == -1)
+ strerr_diefu2sys(111, "chdir to ", argv[1]) ;
+ xexec(argv+2) ;
+}
diff --git a/src/execline/deps-exe/cd b/src/execline/deps-exe/cd
new file mode 100644
index 0000000..e7187fe
--- /dev/null
+++ b/src/execline/deps-exe/cd
@@ -0,0 +1 @@
+-lskarnet
diff --git a/src/execline/deps-exe/execline-cd b/src/execline/deps-exe/execline-cd
deleted file mode 100644
index e7187fe..0000000
--- a/src/execline/deps-exe/execline-cd
+++ /dev/null
@@ -1 +0,0 @@
--lskarnet
diff --git a/src/execline/deps-exe/execline-umask b/src/execline/deps-exe/execline-umask
deleted file mode 100644
index e7187fe..0000000
--- a/src/execline/deps-exe/execline-umask
+++ /dev/null
@@ -1 +0,0 @@
--lskarnet
diff --git a/src/execline/deps-exe/posix-cd b/src/execline/deps-exe/posix-cd
deleted file mode 100644
index e7187fe..0000000
--- a/src/execline/deps-exe/posix-cd
+++ /dev/null
@@ -1 +0,0 @@
--lskarnet
diff --git a/src/execline/deps-exe/posix-umask b/src/execline/deps-exe/posix-umask
deleted file mode 100644
index e7187fe..0000000
--- a/src/execline/deps-exe/posix-umask
+++ /dev/null
@@ -1 +0,0 @@
--lskarnet
diff --git a/src/execline/deps-exe/umask b/src/execline/deps-exe/umask
new file mode 100644
index 0000000..e7187fe
--- /dev/null
+++ b/src/execline/deps-exe/umask
@@ -0,0 +1 @@
+-lskarnet
diff --git a/src/execline/emptyenv.c b/src/execline/emptyenv.c
index ac59697..ed1a893 100644
--- a/src/execline/emptyenv.c
+++ b/src/execline/emptyenv.c
@@ -19,22 +19,22 @@
enum emptyenv_golb_e
{
- GOLB_PATH = 0x01,
- GOLB_LIB = 0x02,
- GOLB_CLEANUP = 0x04,
- GOLB_OPT = 0x08,
- GOLB_POS = 0x10
+ EMPTYENV_GOLB_PATH = 0x01,
+ EMPTYENV_GOLB_LIB = 0x02,
+ EMPTYENV_GOLB_CLEANUP = 0x04,
+ EMPTYENV_GOLB_OPT = 0x08,
+ EMPTYENV_GOLB_POS = 0x10
} ;
int main (int argc, char const *const *argv)
{
static gol_bool const rgolb[5] =
{
- { .so = 'p', .lo = "keep-path", .clear = 0, .set = GOLB_PATH },
- { .so = 'l', .lo = "keep-ld-library-path", .clear = 0, .set = GOLB_LIB },
- { .so = 'c', .lo = "cleanup", .clear = 0, .set = GOLB_CLEANUP },
- { .so = 'o', .lo = "pop-elgetopt", .clear = 0, .set = GOLB_OPT },
- { .so = 'P', .lo = "pop-execline", .clear = 0, .set = GOLB_POS }
+ { .so = 'p', .lo = "keep-path", .clear = 0, .set = EMPTYENV_GOLB_PATH },
+ { .so = 'l', .lo = "keep-ld-library-path", .clear = 0, .set = EMPTYENV_GOLB_LIB },
+ { .so = 'c', .lo = "cleanup", .clear = 0, .set = EMPTYENV_GOLB_CLEANUP },
+ { .so = 'o', .lo = "pop-elgetopt", .clear = 0, .set = EMPTYENV_GOLB_OPT },
+ { .so = 'P', .lo = "pop-execline", .clear = 0, .set = EMPTYENV_GOLB_POS }
} ;
uint64_t wgolb = 0 ;
unsigned int golc ;
@@ -43,7 +43,7 @@ int main (int argc, char const *const *argv)
argc -= golc ; argv += golc ;
if (!argc) strerr_dieusage(100, USAGE) ;
- if (wgolb & GOLB_CLEANUP)
+ if (wgolb & EMPTYENV_GOLB_CLEANUP)
{
static char const *const onebyte = "!?#0" ;
char *const *envp = environ ;
@@ -88,12 +88,12 @@ int main (int argc, char const *const *argv)
strerr_diefu1sys(111, "clean up environment") ;
}
- else if (wgolb & (GOLB_OPT | GOLB_POS))
+ else if (wgolb & (EMPTYENV_GOLB_OPT | EMPTYENV_GOLB_POS))
{
static char const *const list[12] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "#", "ELGETOPT_" } ;
stralloc sa = STRALLOC_ZERO ;
size_t envlen = env_len((char const *const *)environ) ;
- int n = el_popenv(&sa, (char const *const *)environ, envlen, wgolb & GOLB_POS ? list : list + 11, (wgolb & GOLB_POS ? 11 : 0) + !!(wgolb & GOLB_OPT)) ;
+ int n = el_popenv(&sa, (char const *const *)environ, envlen, wgolb & EMPTYENV_GOLB_POS ? list : list + 11, (wgolb & EMPTYENV_GOLB_POS ? 11 : 0) + !!(wgolb & EMPTYENV_GOLB_OPT)) ;
if (n < 0) strerr_diefu1sys(111, "pop current execline environment") ;
{
char const *v[envlen - n + 1] ;
@@ -108,18 +108,18 @@ int main (int argc, char const *const *argv)
char const *newenv[3] = { 0, 0, 0 } ;
char *const *envp = environ ;
unsigned int m = 0 ;
- wgolb &= GOLB_PATH | GOLB_LIB ;
+ wgolb &= EMPTYENV_GOLB_PATH | EMPTYENV_GOLB_LIB ;
for (; wgolb && *envp ; envp++)
{
- if (wgolb & GOLB_PATH && !strncmp(*envp, "PATH=", 5))
+ if (wgolb & EMPTYENV_GOLB_PATH && !strncmp(*envp, "PATH=", 5))
{
newenv[m++] = *envp ;
- wgolb &= ~GOLB_PATH ;
+ wgolb &= ~EMPTYENV_GOLB_PATH ;
}
- if (wgolb & GOLB_LIB && !strncmp(*envp, "LD_LIBRARY_PATH=", 16))
+ if (wgolb & EMPTYENV_GOLB_LIB && !strncmp(*envp, "LD_LIBRARY_PATH=", 16))
{
newenv[m++] = *envp ;
- wgolb &= ~GOLB_LIB ;
+ wgolb &= ~EMPTYENV_GOLB_LIB ;
}
}
xexec_e(argv, newenv) ;
diff --git a/src/execline/execline-cd.c b/src/execline/execline-cd.c
deleted file mode 100644
index 1762708..0000000
--- a/src/execline/execline-cd.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/* ISC license. */
-
-#include
-
-#include
-#include
-
-#define USAGE "cd path prog..."
-
-int main (int argc, char const *const *argv)
-{
- PROG = "execline-cd" ;
- if (argc < 3) strerr_dieusage(100, USAGE) ;
- if (chdir(argv[1]) == -1)
- strerr_diefu2sys(111, "chdir to ", argv[1]) ;
- xexec(argv+2) ;
-}
diff --git a/src/execline/execline-umask.c b/src/execline/execline-umask.c
deleted file mode 100644
index c5aacda..0000000
--- a/src/execline/execline-umask.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* ISC license. */
-
-#include
-
-#include
-#include
-#include
-
-#define USAGE "umask value prog..."
-
-int main (int argc, char const *const *argv)
-{
- unsigned int m ;
- PROG = "execline-umask" ;
- if (argc < 3) strerr_dieusage(100, USAGE) ;
- if (!uint_oscan(argv[1], &m)) strerr_dieusage(100, USAGE) ;
- umask(m) ;
- xexec(argv+2) ;
-}
diff --git a/src/execline/loopwhilex.c b/src/execline/loopwhilex.c
index acae3b3..fdd05b8 100644
--- a/src/execline/loopwhilex.c
+++ b/src/execline/loopwhilex.c
@@ -1,73 +1,91 @@
/* ISC license. */
+#include
+#include
#include
-#include
-#include
+#include
+#include
#include
+#include
#include
#include
-#define USAGE "loopwhilex [ -n ] [ -o okcode,okcode,... | -x exitcode,exitcode,... ] prog..."
+#define USAGE "loopwhilex [ -o okcode,okcode,... | -x exitcode,exitcode,... ] prog..."
#define dieusage() strerr_dieusage(100, USAGE)
-static int lw_isok (unsigned short *tab, unsigned int n, int code)
+enum lw_gola_e
+{
+ LW_GOLA_OK,
+ LW_GOLA_EXCLUDE,
+ LW_GOLA_N
+} ;
+
+static int lw_uint8_cmp (void const *a, void const *b)
+{
+ uint8_t aa = *(uint8_t const *)a ;
+ uint8_t bb = *(uint8_t const *)b ;
+ return aa < bb ? -1 : aa > bb ;
+}
+
+static size_t lw_scanlist (char const *s, uint8_t *tab)
{
- unsigned int i = 0 ;
- for (; i < n ; i++) if ((unsigned short)code == tab[i]) break ;
- return i < n ;
+ size_t n = 0 ;
+ while (*s)
+ {
+ uint64_t u ;
+ size_t l = uint64_scan(s, &u) ;
+ if (!l) break ;
+ if (u > 256 || n >= 255) dieusage() ;
+ tab[n++] = u ;
+ s += l ;
+ while (*s == ',') s++ ;
+ }
+ if (*s) dieusage() ;
+ qsort(tab, n, 1, &lw_uint8_cmp) ;
+ return n ;
}
int main (int argc, char const *const *argv, char const *const *envp)
{
- int wstat ;
- int not = 0, cont = 1, rev = 0 ;
- unsigned short okcodes[256] ;
- size_t nbc = 0 ;
+ static gol_arg const rgola[] =
+ {
+ { .so = 'o', .lo = "ok-codes", .i = LW_GOLA_OK },
+ { .so = 'x', .lo = "exclude-codes", .i = LW_GOLA_EXCLUDE },
+ } ;
+ int rev = 0 ;
+ char const *wgola[LW_GOLA_N] = { 0 } ;
+ size_t n = 0 ;
+ uint8_t codes[256] = { 0 } ;
PROG = "loopwhilex" ;
+
{
- subgetopt l = SUBGETOPT_ZERO ;
- for (;;)
- {
- int opt = subgetopt_r(argc, argv, "no:x:", &l) ;
- if (opt == -1) break ;
- switch (opt)
- {
- case 'n' : not = 1 ; break ;
- case 'o' :
- rev = 0 ;
- if (!ushort_scanlist(okcodes, 256, l.arg, &nbc)) dieusage() ;
- break ;
- case 'x' :
- rev = 1 ;
- if (!ushort_scanlist(okcodes, 256, l.arg, &nbc)) dieusage() ;
- break ;
- default : dieusage() ;
- }
- }
- argc -= l.ind ; argv += l.ind ;
+ unsigned int golc = gol_main(argc, argv, 0, 0, rgola, sizeof(rgola)/sizeof(gol_arg), 0, wgola) ;
+ argc -= golc ; argv += golc ;
}
if (!argc) dieusage() ;
-
- if (!nbc)
+ if (wgola[LW_GOLA_OK]) n = lw_scanlist(wgola[LW_GOLA_OK], codes) ;
+ else if (wgola[LW_GOLA_EXCLUDE])
{
- okcodes[0] = 0 ;
- nbc = 1 ;
+ n = lw_scanlist(wgola[LW_GOLA_EXCLUDE], codes) ;
+ rev = 1 ;
}
- else if (rev) not = !not ;
+ else n = 1 ;
- while (cont)
+ for (;;)
{
+ int wstat ;
pid_t pid = el_spawn0(argv[0], argv, envp) ;
if (!pid)
{
if (errno == ENOENT && argv[0][0] == ' ')
- strerr_diefu3x(111, "spawn ", argv[0], ": name begins with a space, are you trying to spawn a block as your loop body?") ;
- else strerr_diefu2sys(111, "spawn ", argv[0]) ;
+ strerr_dief(111, "spawn ", argv[0], ": name begins with a space, are you trying to spawn a block as your loop body?") ;
+ else strerr_diefusys(111, "spawn ", argv[0]) ;
}
- if (wait_pid(pid, &wstat) < 0) strerr_diefu1sys(111, "wait_pid") ;
- cont = not != lw_isok(okcodes, nbc, wait_estatus(wstat)) ;
+ if (wait_pid(pid, &wstat) < 0) strerr_diefusys(111, "wait_pid") ;
+ codes[255] = wait_estatus(wstat) ;
+ if (rev != !bsearch(codes + 255, codes, n, 1, &lw_uint8_cmp)) break ;
}
- return wait_estatus(wstat) ;
+ return codes[255] ;
}
diff --git a/src/execline/posix-cd.c b/src/execline/posix-cd.c
deleted file mode 100644
index e9bfd35..0000000
--- a/src/execline/posix-cd.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/* ISC license. */
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#define USAGE "posix-cd [ -L | -P ] [ - | path ] [ prog... ]"
-#define dieusage() strerr_dieusage(100, USAGE)
-#define dienomem() strerr_diefu1sys(111, "stralloc_catb")
-
-int main (int argc, char const **argv)
-{
- int phy = 0 ;
- int dopwd = 0 ;
- char const *where ;
- int got = 0 ;
- stralloc sa = STRALLOC_ZERO ;
- PROG = "posix-cd" ;
- setlocale(LC_ALL, "") ; /* yeah, as if */
-
- {
- subgetopt l = SUBGETOPT_ZERO ;
- for (;;)
- {
- int opt = subgetopt_r(argc, argv, "LP", &l) ;
- if (opt == -1) break ;
- switch (opt)
- {
- case 'L' : phy = 0 ; break ;
- case 'P' : phy = 1 ; break ;
- default : dieusage() ;
- }
- }
- argc -= l.ind ; argv += l.ind ;
- }
- if (!argc) where = getenv("HOME") ;
- else
- {
- where = *argv++ ;
- if (!strcmp(where, "-"))
- {
- where = getenv("OLDPWD") ;
- dopwd = 1 ;
- }
- }
- if (!where || !where[0]) dieusage() ;
-
- if (!(where[0] == '/' || (where[0] == '.' && (!where[1] || where[1] == '/' || (where[1] == '.' && (!where[2] || where[2] == '/'))))))
- {
- char const *cdpath = getenv("CDPATH") ;
- if (cdpath)
- {
- size_t pos = 0 ;
- size_t len = strlen(cdpath) ;
- while (pos < len)
- {
- struct stat st ;
- size_t m = byte_chr(cdpath + pos, len - pos, ':') ;
- sa.len = 0 ;
- if (m)
- {
- if (!stralloc_catb(&sa, cdpath + pos, m)) dienomem() ;
- if (cdpath[pos + m - 1] != '/' && !stralloc_catb(&sa, "/", 1)) dienomem() ;
- }
- else if (!stralloc_catb(&sa, "./", 2)) dienomem() ;
- if (!stralloc_cats(&sa, where) || !stralloc_0(&sa)) dienomem() ;
- if (!stat(sa.s, &st) && S_ISDIR(st.st_mode))
- {
- got = 1 ;
- dopwd = 1 ;
- break ;
- }
- pos += m+1 ;
- }
- }
- }
-
- if (!got && (!stralloc_cats(&sa, where) || !stralloc_0(&sa))) dienomem() ;
-
- {
- size_t sabase = sa.len ;
- if (sagetcwd(&sa) < 0) strerr_diefu1sys(111, "getcwd") ;
- if (!stralloc_0(&sa)) dienomem() ;
- if (!env_mexec("OLDPWD", sa.s + sabase)) dienomem() ;
- sa.len = sabase ;
- }
-
- if (!phy)
- {
- char const *x = getenv("PWD") ;
- if (x && sa.s[0] != '/')
- {
- size_t len = strlen(x) ;
- int doslash = len && x[len-1] != '/' ;
- if (!stralloc_insertb(&sa, 0, x, len + doslash)) dienomem() ;
- if (doslash) sa.s[len] = '/' ;
- }
- {
- stralloc tmp = STRALLOC_ZERO ;
- if (!stralloc_ready(&tmp, sa.len + 2)) dienomem() ;
- tmp.len = path_canonicalize(tmp.s, sa.s, 1) ;
- if (!tmp.len++)
- strerr_diefu4sys(111, "canonicalize ", sa.s, ": problem with ", tmp.s) ;
- stralloc_free(&sa) ;
- sa = tmp ;
- }
- if (!env_mexec("PWD", sa.s)) dienomem() ;
-#ifdef PATH_MAX
- if (sa.len > PATH_MAX && strlen(where) < PATH_MAX && x && *x)
- {
- size_t len = strlen(x) ;
- int hasslash = x[len-1] == '/' ;
- if (!strncmp(sa.s, x, len))
- {
- if (hasslash || (sa.len > len && sa.s[len] == '/'))
- {
- sa.len -= len + !hasslash ;
- memmove(sa.s, sa.s + len + !hasslash, sa.len) ;
- }
- }
- }
-#endif
- }
-
- /* fking finally */
-
- if (chdir(sa.s) < 0)
- strerr_diefu2sys(111, "chdir to ", where) ;
-
- /* and there's still more nonsense to do afterwards! */
-
- if (phy)
- {
- sa.len = 0 ;
- if (sagetcwd(&sa) < 0) strerr_diefu1sys(111, "getcwd") ;
- if (!stralloc_0(&sa)) dienomem() ;
- if (!env_mexec("PWD", sa.s)) dienomem() ;
- }
-
- if (dopwd)
- {
- sa.s[sa.len - 1] = '\n' ;
- if (allwrite(1, sa.s, sa.len) < sa.len)
- strerr_diefu1sys(111, "write to stdout") ;
- }
-
- xmexec0(argv) ;
-}
diff --git a/src/execline/posix-umask.c b/src/execline/posix-umask.c
deleted file mode 100644
index 69f4b08..0000000
--- a/src/execline/posix-umask.c
+++ /dev/null
@@ -1,174 +0,0 @@
-/* ISC license. */
-
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#define USAGE "posix-umask [ -S ] [ mask ] [ prog... ]"
-#define dieusage() strerr_dieusage(100, USAGE)
-#define dieout() strerr_diefu1sys(111, "write to stdout")
-
-
- /* well, unlike posix-cd, at least this one was fun to write */
-
-static inline int pu_output (int sym)
-{
- mode_t mode = umask(0) ;
- size_t m = 0 ;
- char fmt[18] ;
- if (sym)
- {
- unsigned int i = 3 ;
- while (i--)
- {
- unsigned int mask = ~(mode >> (3*i)) ;
- fmt[m++] = "ogu"[i] ; fmt[m++] = '=' ;
- if (mask & 4) fmt[m++] = 'r' ;
- if (mask & 2) fmt[m++] = 'w' ;
- if (mask & 1) fmt[m++] = 'x' ;
- if (i) fmt[m++] = ',' ;
- }
- }
- else m += uint0_ofmt(fmt, mode, 4) ;
- fmt[m++] = '\n' ;
- if (buffer_putflush(buffer_1, fmt, m) < 0) dieout() ;
- return 0 ;
-}
-
-static void pu_diesyntax (char const *) gccattr_noreturn ;
-static void pu_diesyntax (char const *s)
-{
- strerr_dief3x(101, "internal parsing error: bad ", s, ". Please submit a bug-report.") ;
-}
-
-static inline uint8_t pu_cclass (char c)
-{
- /* char tables may be more efficient, but this is way more readable */
- switch (c)
- {
- case 0 : return 0 ;
- case ',' : return 1 ;
- case '+' :
- case '-' :
- case '=' : return 2 ;
- case 'u' :
- case 'g' :
- case 'o' : return 3 ;
- case 'a' : return 4 ;
- case 'r' :
- case 'w' :
- case 'x' :
- case 'X' :
- case 's' :
- case 't' : return 5 ;
- default : return 6 ;
- }
-}
-
-static inline uint8_t pu_who_value (char c)
-{
- switch (c)
- {
- case 'u' : return 4 ;
- case 'g' : return 2 ;
- case 'o' : return 1 ;
- case 'a' :
- case '+' : /* shortcut for when who is empty */
- case '-' :
- case '=' : return 7 ;
- default : pu_diesyntax("who") ;
- }
-}
-
-static inline uint8_t pu_perm_value (char c)
-{
- switch (c)
- {
- case 'r' : return 4 ;
- case 'w' : return 2 ;
- case 'x' :
- case 'X' : return 1 ;
- case 's' :
- case 't' : return 0 ;
- default : pu_diesyntax("perm") ;
- }
-}
-
-static inline unsigned int pu_parsemode (char const *s)
-{
- static uint16_t const table[5][7] =
- {
- { 0x005, 0x000, 0x064, 0x021, 0x021, 0x006, 0x006 },
- { 0x005, 0x006, 0x042, 0x021, 0x021, 0x006, 0x006 },
- { 0x005, 0x200, 0x042, 0x083, 0x006, 0x104, 0x006 },
- { 0x805, 0xe00, 0xc42, 0x006, 0x006, 0x006, 0x006 },
- { 0x805, 0xe00, 0xc42, 0x006, 0x006, 0x104, 0x006 }
- } ;
- unsigned int oldmode = ~umask(0) ;
- uint8_t modes[3] = { oldmode & 7, (oldmode >> 3) & 7, (oldmode >> 6) & 7 } ;
- uint8_t who = 0 ;
- uint8_t perm = 0 ;
- uint8_t state = 0 ;
- char op = 0 ;
- while (state < 5)
- {
- char c = *s++ ;
- uint16_t what = table[state][pu_cclass(c)] ;
- state = what & 7 ;
- if (what & 0x020) who |= pu_who_value(c) ;
- if (what & 0x080) perm = modes[byte_chr("ogu", 3, c)] ;
- if (what & 0x100) perm |= pu_perm_value(c) ;
- if (what & 0x800)
- {
- unsigned int i = 3 ;
- while (i--) if (who & (1 << i))
- switch (op)
- {
- case '-' : modes[i] &= ~perm ; break ;
- case '+' : modes[i] |= perm ; break ;
- case '=' : modes[i] = perm ; break ;
- default : pu_diesyntax("op") ;
- }
- }
- if (what & 0x040) op = c ;
- if (what & 0x200) who = 0 ;
- if (what & 0x400) perm = 0 ;
- }
- if (state > 5) strerr_dief1x(1, "invalid mode string") ;
- return ((unsigned int)modes[2] << 6) | ((unsigned int)modes[1] << 3) | modes[0] ;
-}
-
-int main (int argc, char const **argv)
-{
- int sym = 0 ;
- unsigned int mode ;
- PROG = "posix-umask" ;
- setlocale(LC_ALL, "") ; /* totally supported, I swear */
-
- {
- subgetopt l = SUBGETOPT_ZERO ;
- for (;;)
- {
- int opt = subgetopt_r(argc, argv, "S", &l) ;
- if (opt == -1) break ;
- switch (opt)
- {
- case 'S' : sym = 1 ; break ;
- default : dieusage() ;
- }
- }
- argc -= l.ind ; argv += l.ind ;
- }
- if (!argc) return pu_output(sym) ;
- if (!uint0_oscan(argv[0], &mode)) mode = ~pu_parsemode(argv[0]) ;
- umask(mode & 00777) ;
- xexec0(argv+1) ;
-}
diff --git a/src/execline/posix-umask.txt b/src/execline/posix-umask.txt
deleted file mode 100644
index 5bf49a2..0000000
--- a/src/execline/posix-umask.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-
- parsemode() function for posix-umask
-
- goal: parse the "u+r,g-wx,o=u" symbolic mode string and convert it
-to a numeric value suitable for umask().
- In the purest skarnet.org tradition, we implement the parser via a DFA.
-
-class | 0 1 2 3 4 5 6
-st\ev | \0 , +-= ugo a rwxXst other
-------------------------------------------------------------------------
-START | wo w w
-0 | END START OP WHO WHO X X
-
-WHO | o w w
-1 | END X OP WHO WHO X X
-
-OP | r o c p
-2 | END START OP PERMCPY X PERM X
-
-PERMCPY | ! !rR !Ro
-3 | END START OP X X X X
-
-PERM | ! !rR !Ro p
-4 | END START OP X X PERM X
-------------------------------------------------------------------------
-
-END=5, X=6. -> states: 3 bits
-7 actions -> 10 bits total, need uint16_t
-
- w: 0x020: who |= c
- o: 0x040: store op
- c: 0x080: copy perm from c
- p: 0x100: perm |= c
- r: 0x200: reset who
- R: 0x400: reset perm
- !: 0x800: apply (who, op, perm) change
-
diff --git a/src/execline/redirfd.c b/src/execline/redirfd.c
index c3562f9..c9a7f9e 100644
--- a/src/execline/redirfd.c
+++ b/src/execline/redirfd.c
@@ -13,47 +13,47 @@
#define USAGE "redirfd -[ r | w | u | a | x ] [ -N | -n ] [ -b ] [ -f ] [ -E | -e ] fd|var file prog..."
#define dieusage() strerr_dieusage(100, USAGE)
-enum golb_e
+enum redirfd_golb_e
{
- GOLB_READ = 0x0001,
- GOLB_WRITE = 0x0002,
- GOLB_CREAT = 0x0004,
- GOLB_APPEND = 0x0008,
- GOLB_TRUNC = 0x0010,
- GOLB_EXCL = 0x0020,
- GOLB_NONBLOCK = 0x0040,
- GOLB_CHANGEMODE = 0x0100,
- GOLB_OPEN = 0x0200,
- GOLB_AUTOIMPORT = 0x0400,
+ REDIRFD_GOLB_READ = 0x0001,
+ REDIRFD_GOLB_WRITE = 0x0002,
+ REDIRFD_GOLB_CREAT = 0x0004,
+ REDIRFD_GOLB_APPEND = 0x0008,
+ REDIRFD_GOLB_TRUNC = 0x0010,
+ REDIRFD_GOLB_EXCL = 0x0020,
+ REDIRFD_GOLB_NONBLOCK = 0x0040,
+ REDIRFD_GOLB_CHANGEMODE = 0x0100,
+ REDIRFD_GOLB_OPEN = 0x0200,
+ REDIRFD_GOLB_AUTOIMPORT = 0x0400,
} ;
int main (int argc, char const *const *argv)
{
static gol_bool const rgolb[] =
{
- { .so = 'r', .lo = 0, .clear = GOLB_WRITE | GOLB_APPEND | GOLB_CREAT | GOLB_TRUNC | GOLB_EXCL, .set = GOLB_READ },
- { .so = 'w', .lo = 0, .clear = GOLB_READ | GOLB_APPEND | GOLB_EXCL, .set = GOLB_WRITE | GOLB_CREAT | GOLB_TRUNC },
- { .so = 'u', .lo = 0, .clear = GOLB_APPEND | GOLB_CREAT | GOLB_TRUNC | GOLB_EXCL, .set = GOLB_READ | GOLB_WRITE },
- { .so = 'a', .lo = 0, .clear = GOLB_READ | GOLB_TRUNC | GOLB_EXCL, .set = GOLB_WRITE | GOLB_CREAT | GOLB_APPEND },
- { .so = 'x', .lo = 0, .clear = GOLB_READ | GOLB_APPEND | GOLB_TRUNC, .set = GOLB_WRITE | GOLB_CREAT | GOLB_EXCL },
- { .so = 'N', .lo = "block", .clear = GOLB_NONBLOCK, .set = 0 },
- { .so = 'n', .lo = "nonblock", .clear = 0, .set = GOLB_NONBLOCK },
- { .so = 'b', .lo = "switch-block", .clear = 0, .set = GOLB_CHANGEMODE },
- { .so = 'f', .lo = "open", .clear = 0, .set = GOLB_OPEN },
- { .so = 'e', .lo = "no-autoimport", .clear = GOLB_AUTOIMPORT, .set = 0 },
- { .so = 'E', .lo = "autoimport", .clear = 0, .set = GOLB_AUTOIMPORT },
- { .so = 0, .lo = "no-read", .clear = GOLB_READ, .set = 0 },
- { .so = 0, .lo = "read", .clear = 0, .set = GOLB_READ },
- { .so = 0, .lo = "no-write", .clear = GOLB_WRITE, .set = 0 },
- { .so = 0, .lo = "write", .clear = 0, .set = GOLB_WRITE },
- { .so = 0, .lo = "no-create", .clear = GOLB_CREAT, .set = 0 },
- { .so = 0, .lo = "create", .clear = 0, .set = GOLB_CREAT },
- { .so = 0, .lo = "no-append", .clear = GOLB_APPEND, .set = 0 },
- { .so = 0, .lo = "append", .clear = 0, .set = GOLB_APPEND },
- { .so = 0, .lo = "no-trunc", .clear = GOLB_TRUNC, .set = 0 },
- { .so = 0, .lo = "trunc", .clear = 0, .set = GOLB_TRUNC },
- { .so = 0, .lo = "no-excl", .clear = GOLB_EXCL, .set = 0 },
- { .so = 0, .lo = "excl", .clear = 0, .set = GOLB_EXCL },
+ { .so = 'r', .lo = 0, .clear = REDIRFD_GOLB_WRITE | REDIRFD_GOLB_APPEND | REDIRFD_GOLB_CREAT | REDIRFD_GOLB_TRUNC | REDIRFD_GOLB_EXCL, .set = REDIRFD_GOLB_READ },
+ { .so = 'w', .lo = 0, .clear = REDIRFD_GOLB_READ | REDIRFD_GOLB_APPEND | REDIRFD_GOLB_EXCL, .set = REDIRFD_GOLB_WRITE | REDIRFD_GOLB_CREAT | REDIRFD_GOLB_TRUNC },
+ { .so = 'u', .lo = 0, .clear = REDIRFD_GOLB_APPEND | REDIRFD_GOLB_CREAT | REDIRFD_GOLB_TRUNC | REDIRFD_GOLB_EXCL, .set = REDIRFD_GOLB_READ | REDIRFD_GOLB_WRITE },
+ { .so = 'a', .lo = 0, .clear = REDIRFD_GOLB_READ | REDIRFD_GOLB_TRUNC | REDIRFD_GOLB_EXCL, .set = REDIRFD_GOLB_WRITE | REDIRFD_GOLB_CREAT | REDIRFD_GOLB_APPEND },
+ { .so = 'x', .lo = 0, .clear = REDIRFD_GOLB_READ | REDIRFD_GOLB_APPEND | REDIRFD_GOLB_TRUNC, .set = REDIRFD_GOLB_WRITE | REDIRFD_GOLB_CREAT | REDIRFD_GOLB_EXCL },
+ { .so = 'N', .lo = "block", .clear = REDIRFD_GOLB_NONBLOCK, .set = 0 },
+ { .so = 'n', .lo = "nonblock", .clear = 0, .set = REDIRFD_GOLB_NONBLOCK },
+ { .so = 'b', .lo = "switch-block", .clear = 0, .set = REDIRFD_GOLB_CHANGEMODE },
+ { .so = 'f', .lo = "open", .clear = 0, .set = REDIRFD_GOLB_OPEN },
+ { .so = 'e', .lo = "no-autoimport", .clear = REDIRFD_GOLB_AUTOIMPORT, .set = 0 },
+ { .so = 'E', .lo = "autoimport", .clear = 0, .set = REDIRFD_GOLB_AUTOIMPORT },
+ { .so = 0, .lo = "no-read", .clear = REDIRFD_GOLB_READ, .set = 0 },
+ { .so = 0, .lo = "read", .clear = 0, .set = REDIRFD_GOLB_READ },
+ { .so = 0, .lo = "no-write", .clear = REDIRFD_GOLB_WRITE, .set = 0 },
+ { .so = 0, .lo = "write", .clear = 0, .set = REDIRFD_GOLB_WRITE },
+ { .so = 0, .lo = "no-create", .clear = REDIRFD_GOLB_CREAT, .set = 0 },
+ { .so = 0, .lo = "create", .clear = 0, .set = REDIRFD_GOLB_CREAT },
+ { .so = 0, .lo = "no-append", .clear = REDIRFD_GOLB_APPEND, .set = 0 },
+ { .so = 0, .lo = "append", .clear = 0, .set = REDIRFD_GOLB_APPEND },
+ { .so = 0, .lo = "no-trunc", .clear = REDIRFD_GOLB_TRUNC, .set = 0 },
+ { .so = 0, .lo = "trunc", .clear = 0, .set = REDIRFD_GOLB_TRUNC },
+ { .so = 0, .lo = "no-excl", .clear = REDIRFD_GOLB_EXCL, .set = 0 },
+ { .so = 0, .lo = "excl", .clear = 0, .set = REDIRFD_GOLB_EXCL },
} ;
uint64_t wgolb = 0 ;
unsigned int golc ;
@@ -65,20 +65,20 @@ int main (int argc, char const *const *argv)
golc = gol_main(argc, argv, rgolb, sizeof(rgolb)/sizeof(gol_bool), 0, 0, &wgolb, 0) ;
argc -= golc ; argv += golc ;
if (argc < 3) dieusage() ;
- if (!(wgolb & (GOLB_READ | GOLB_WRITE))) dieusage() ;
- if (!(wgolb & GOLB_OPEN))
+ if (!(wgolb & (REDIRFD_GOLB_READ | REDIRFD_GOLB_WRITE))) dieusage() ;
+ if (!(wgolb & REDIRFD_GOLB_OPEN))
if (!uint0_scan(argv[0], &fdto)) dieusage() ;
flags =
- (wgolb & GOLB_WRITE ? wgolb & GOLB_READ ? O_RDWR : O_WRONLY : O_RDONLY) |
- (wgolb & GOLB_CREAT ? O_CREAT : 0) |
- (wgolb & GOLB_APPEND ? O_APPEND : 0) |
- (wgolb & GOLB_TRUNC ? O_TRUNC : 0) |
- (wgolb & GOLB_EXCL ? O_EXCL : 0) |
- (wgolb & GOLB_NONBLOCK ? O_NONBLOCK : 0) ;
+ (wgolb & REDIRFD_GOLB_WRITE ? wgolb & REDIRFD_GOLB_READ ? O_RDWR : O_WRONLY : O_RDONLY) |
+ (wgolb & REDIRFD_GOLB_CREAT ? O_CREAT : 0) |
+ (wgolb & REDIRFD_GOLB_APPEND ? O_APPEND : 0) |
+ (wgolb & REDIRFD_GOLB_TRUNC ? O_TRUNC : 0) |
+ (wgolb & REDIRFD_GOLB_EXCL ? O_EXCL : 0) |
+ (wgolb & REDIRFD_GOLB_NONBLOCK ? O_NONBLOCK : 0) ;
fd = open3(argv[1], flags, 0666) ;
- if (fd == -1 && wgolb & GOLB_WRITE && errno == ENXIO)
+ if (fd == -1 && wgolb & REDIRFD_GOLB_WRITE && errno == ENXIO)
{
int fdr = open_read(argv[1]) ;
if (fdr == -1) strerr_diefu2sys(111, "open_read ", argv[1]) ;
@@ -87,14 +87,14 @@ int main (int argc, char const *const *argv)
}
if (fd == -1) strerr_diefu2sys(111, "open ", argv[1]) ;
- if (wgolb & GOLB_CHANGEMODE)
- if ((wgolb & GOLB_NONBLOCK ? ndelay_off(fd) : ndelay_on(fd)) == -1)
+ if (wgolb & REDIRFD_GOLB_CHANGEMODE)
+ if ((wgolb & REDIRFD_GOLB_NONBLOCK ? ndelay_off(fd) : ndelay_on(fd)) == -1)
strerr_diefu1sys(111, "change blocking mode") ;
- if (wgolb & GOLB_OPEN)
+ if (wgolb & REDIRFD_GOLB_OPEN)
{
char fmt[UINT_FMT] ;
fmt[uint_fmt(fmt, fd)] = 0 ;
- el_modif_and_exec(argv+2, argv[0], fmt, !!(wgolb & GOLB_AUTOIMPORT)) ;
+ el_modif_and_exec(argv+2, argv[0], fmt, !!(wgolb & REDIRFD_GOLB_AUTOIMPORT)) ;
}
else
{
diff --git a/src/execline/umask.c b/src/execline/umask.c
new file mode 100644
index 0000000..819cf96
--- /dev/null
+++ b/src/execline/umask.c
@@ -0,0 +1,158 @@
+/* ISC license. */
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#define USAGE "umask [ -S ] [ mask ] [ prog... ]"
+#define dieusage() strerr_dieusage(100, USAGE)
+#define dieout() strerr_diefu1sys(111, "write to stdout")
+
+static inline int umask_output (int sym)
+{
+ mode_t mode = umask(0) ;
+ size_t m = 0 ;
+ char fmt[18] ;
+ if (sym)
+ {
+ unsigned int i = 3 ;
+ while (i--)
+ {
+ unsigned int mask = ~(mode >> (3*i)) ;
+ fmt[m++] = "ogu"[i] ; fmt[m++] = '=' ;
+ if (mask & 4) fmt[m++] = 'r' ;
+ if (mask & 2) fmt[m++] = 'w' ;
+ if (mask & 1) fmt[m++] = 'x' ;
+ if (i) fmt[m++] = ',' ;
+ }
+ }
+ else m += uint0_ofmt(fmt, mode, 4) ;
+ fmt[m++] = '\n' ;
+ if (buffer_putflush(buffer_1, fmt, m) < 0) dieout() ;
+ return 0 ;
+}
+
+static void umask_diesyntax (char const *) gccattr_noreturn ;
+static void umask_diesyntax (char const *s)
+{
+ strerr_dief(101, "internal parsing error: bad ", s, ". Please submit a bug-report.") ;
+}
+
+static inline uint8_t pu_cclass (char c)
+{
+ /* char tables may be more efficient, but this is way more readable */
+ switch (c)
+ {
+ case 0 : return 0 ;
+ case ',' : return 1 ;
+ case '+' :
+ case '-' :
+ case '=' : return 2 ;
+ case 'u' :
+ case 'g' :
+ case 'o' : return 3 ;
+ case 'a' : return 4 ;
+ case 'r' :
+ case 'w' :
+ case 'x' :
+ case 'X' :
+ case 's' :
+ case 't' : return 5 ;
+ default : return 6 ;
+ }
+}
+
+static inline uint8_t umask_who_value (char c)
+{
+ switch (c)
+ {
+ case 'u' : return 4 ;
+ case 'g' : return 2 ;
+ case 'o' : return 1 ;
+ case 'a' :
+ case '+' : /* shortcut for when who is empty */
+ case '-' :
+ case '=' : return 7 ;
+ default : umask_diesyntax("who") ;
+ }
+}
+
+static inline uint8_t umask_perm_value (char c)
+{
+ switch (c)
+ {
+ case 'r' : return 4 ;
+ case 'w' : return 2 ;
+ case 'x' :
+ case 'X' : return 1 ;
+ case 's' :
+ case 't' : return 0 ;
+ default : umask_diesyntax("perm") ;
+ }
+}
+
+static inline unsigned int umask_parsemode (char const *s)
+{
+ static uint16_t const table[5][7] =
+ {
+ { 0x005, 0x000, 0x064, 0x021, 0x021, 0x006, 0x006 },
+ { 0x005, 0x006, 0x042, 0x021, 0x021, 0x006, 0x006 },
+ { 0x005, 0x200, 0x042, 0x083, 0x006, 0x104, 0x006 },
+ { 0x805, 0xe00, 0xc42, 0x006, 0x006, 0x006, 0x006 },
+ { 0x805, 0xe00, 0xc42, 0x006, 0x006, 0x104, 0x006 }
+ } ;
+ unsigned int oldmode = ~umask(0) ;
+ uint8_t modes[3] = { oldmode & 7, (oldmode >> 3) & 7, (oldmode >> 6) & 7 } ;
+ uint8_t who = 0 ;
+ uint8_t perm = 0 ;
+ uint8_t state = 0 ;
+ char op = 0 ;
+ while (state < 5)
+ {
+ char c = *s++ ;
+ uint16_t what = table[state][pu_cclass(c)] ;
+ state = what & 7 ;
+ if (what & 0x020) who |= umask_who_value(c) ;
+ if (what & 0x080) perm = modes[byte_chr("ogu", 3, c)] ;
+ if (what & 0x100) perm |= umask_perm_value(c) ;
+ if (what & 0x800)
+ {
+ unsigned int i = 3 ;
+ while (i--) if (who & (1 << i))
+ switch (op)
+ {
+ case '-' : modes[i] &= ~perm ; break ;
+ case '+' : modes[i] |= perm ; break ;
+ case '=' : modes[i] = perm ; break ;
+ default : umask_diesyntax("op") ;
+ }
+ }
+ if (what & 0x040) op = c ;
+ if (what & 0x200) who = 0 ;
+ if (what & 0x400) perm = 0 ;
+ }
+ if (state > 5) strerr_dief1x(1, "invalid mode string") ;
+ return ((unsigned int)modes[2] << 6) | ((unsigned int)modes[1] << 3) | modes[0] ;
+}
+
+int main (int argc, char const **argv)
+{
+ static gol_bool const rgolb = { .so = 'S', .lo = "symbolic", .clear = 0, .set = 0x01 } ;
+ uint64_t wgolb = 0 ;
+ unsigned int mode ;
+ PROG = "umask" ;
+
+ {
+ unsigned int golc = gol_main(argc, argv, &rgolb, 1, 0, 0, &wgolb, 0) ;
+ argc -= golc ; argv += golc ;
+ }
+ if (!argc) return umask_output(wgolb & 0x01) ;
+ if (!uint0_oscan(argv[0], &mode)) mode = ~umask_parsemode(argv[0]) ;
+ umask(mode & 00777) ;
+ xexec0(argv+1) ;
+}
diff --git a/src/execline/umask.txt b/src/execline/umask.txt
new file mode 100644
index 0000000..5bf49a2
--- /dev/null
+++ b/src/execline/umask.txt
@@ -0,0 +1,37 @@
+
+ parsemode() function for posix-umask
+
+ goal: parse the "u+r,g-wx,o=u" symbolic mode string and convert it
+to a numeric value suitable for umask().
+ In the purest skarnet.org tradition, we implement the parser via a DFA.
+
+class | 0 1 2 3 4 5 6
+st\ev | \0 , +-= ugo a rwxXst other
+------------------------------------------------------------------------
+START | wo w w
+0 | END START OP WHO WHO X X
+
+WHO | o w w
+1 | END X OP WHO WHO X X
+
+OP | r o c p
+2 | END START OP PERMCPY X PERM X
+
+PERMCPY | ! !rR !Ro
+3 | END START OP X X X X
+
+PERM | ! !rR !Ro p
+4 | END START OP X X PERM X
+------------------------------------------------------------------------
+
+END=5, X=6. -> states: 3 bits
+7 actions -> 10 bits total, need uint16_t
+
+ w: 0x020: who |= c
+ o: 0x040: store op
+ c: 0x080: copy perm from c
+ p: 0x100: perm |= c
+ r: 0x200: reset who
+ R: 0x400: reset perm
+ !: 0x800: apply (who, op, perm) change
+
diff --git a/src/execline/wait.c b/src/execline/wait.c
index 6886c0c..d320d54 100644
--- a/src/execline/wait.c
+++ b/src/execline/wait.c
@@ -15,10 +15,6 @@
#include
#include
-#ifdef EXECLINE_PEDANTIC_POSIX
-#include
-#endif
-
#define USAGE "wait [ -I | -i ] [ -a | -o ] [ -r | -t timeout ] { pids... } [ prog... ]"
#define dieusage() strerr_dieusage(100, USAGE)
@@ -157,51 +153,48 @@ static int wait_with_timeout (pid_t *pids, unsigned int n, pid_t *returned, ac_f
enum wait_golb_e
{
- GOLB_INSIST = 0x01,
- GOLB_JUSTONE = 0x02,
- GOLB_REAP = 0x04,
+ WAIT_GOLB_INSIST = 0x01,
+ WAIT_GOLB_JUSTONE = 0x02,
+ WAIT_GOLB_REAP = 0x04,
} ;
enum wait_gola_e
{
- GOLA_TIMEOUT,
- GOLA_N
+ WAIT_GOLA_TIMEOUT,
+ WAIT_GOLA_N
} ;
int main (int argc, char const **argv)
{
static gol_bool const rgolb[] =
{
- { .so = 'I', .lo = "no-insist", .clear = GOLB_INSIST, .set = 0 },
- { .so = 'i', .lo = "insist", .clear = 0, .set = GOLB_INSIST },
- { .so = 'a', .lo = "all", .clear = GOLB_JUSTONE, .set = 0 },
- { .so = 'o', .lo = "one", .clear = 0, .set = GOLB_JUSTONE },
- { .so = 'r', .lo = "reap", .clear = 0, .set = GOLB_REAP },
+ { .so = 'I', .lo = "no-insist", .clear = WAIT_GOLB_INSIST, .set = 0 },
+ { .so = 'i', .lo = "insist", .clear = 0, .set = WAIT_GOLB_INSIST },
+ { .so = 'a', .lo = "all", .clear = WAIT_GOLB_JUSTONE, .set = 0 },
+ { .so = 'o', .lo = "one", .clear = 0, .set = WAIT_GOLB_JUSTONE },
+ { .so = 'r', .lo = "reap", .clear = 0, .set = WAIT_GOLB_REAP },
} ;
static gol_arg const rgola[] =
{
- { .so = 't', .lo = "timeout", .i = GOLA_TIMEOUT },
+ { .so = 't', .lo = "timeout", .i = WAIT_GOLA_TIMEOUT },
} ;
tain tto = TAIN_INFINITE_RELATIVE ;
int argc1 ;
int hasblock = 1 ;
int e ;
uint64_t wgolb = 0 ;
- char const *wgola[GOLA_N] = { 0 } ;
+ char const *wgola[WAIT_GOLA_N] = { 0 } ;
unsigned int golc ;
pid_t pid = -1 ;
PROG = "wait" ;
-#ifdef EXECLINE_PEDANTIC_POSIX
- setlocale(LC_ALL, "") ; /* but of course, dear POSIX */
-#endif
golc = GOL_main(argc, argv, rgolb, rgola, &wgolb, wgola) ;
argc -= golc ; argv += golc ;
- if (wgolb & GOLB_REAP) wgola[GOLA_TIMEOUT] = "0" ;
- if (wgola[GOLA_TIMEOUT])
+ if (wgolb & WAIT_GOLB_REAP) wgola[WAIT_GOLA_TIMEOUT] = "0" ;
+ if (wgola[WAIT_GOLA_TIMEOUT])
{
unsigned int t = 0 ;
- if (!uint0_scan(wgola[GOLA_TIMEOUT], &t)) dieusage() ;
+ if (!uint0_scan(wgola[WAIT_GOLA_TIMEOUT], &t)) dieusage() ;
tain_from_millisecs(&tto, t) ;
}
@@ -223,9 +216,9 @@ int main (int argc, char const **argv)
}
else pids[0] = 0 ;
- e = wgola[GOLA_TIMEOUT] ? /* wait -t30000 whatever */
- wait_with_timeout(pids, n, &pid, argc1 ? &wait_one_from_list_nohang : &wait_one_nohang, &tto, !!(wgolb & GOLB_JUSTONE), !!(wgolb & GOLB_INSIST)) :
- wgolb & GOLB_JUSTONE ?
+ e = wgola[WAIT_GOLA_TIMEOUT] ? /* wait -t30000 whatever */
+ wait_with_timeout(pids, n, &pid, argc1 ? &wait_one_from_list_nohang : &wait_one_nohang, &tto, !!(wgolb & WAIT_GOLB_JUSTONE), !!(wgolb & WAIT_GOLB_INSIST)) :
+ wgolb & WAIT_GOLB_JUSTONE ?
argc1 ?
wait_one_from_list(pids, n, &pid) : /* wait -o -- 2 3 4 / wait -o -- { 2 3 4 } */
wait_one(&pid) : /* wait -o / wait -o { } */
@@ -234,7 +227,7 @@ int main (int argc, char const **argv)
wait_all() ; /* wait / wait { } */
}
if (!hasblock) _exit(e >= 0 ? e : 127) ;
- if (!(wgolb & GOLB_JUSTONE)) xexec0(argv + argc1 + 1) ;
+ if (!(wgolb & WAIT_GOLB_JUSTONE)) xexec0(argv + argc1 + 1) ;
if (e == -1) xmexec0_n(argv + argc1 + 1, "?\0!", 4, 2) ;
{
diff --git a/tools/gen-multicall.sh b/tools/gen-multicall.sh
index 7a359b4..fe12272 100755
--- a/tools/gen-multicall.sh
+++ b/tools/gen-multicall.sh
@@ -41,7 +41,7 @@ EOF
for i in `ls -1 src/execline/deps-exe` ; do
j=`echo $i | tr - _`
echo
- grep -v '^#include ' < src/execline/${i}.c | grep -vF '/* ISC license. */' | sed -e "s/int main (int argc, char \(.*\)\*argv.*$/int ${j}_main (int argc, char \1*argv, char const *const *envp)/"
+ grep -v '^#include ' < src/execline/${i}.c | grep -vF '/* ISC license. */' | sed -e "s/int main (int argc, char \(.*\)\*argv.*$/static int ${j}_main (int argc, char \1*argv, char const *const *envp)/"
echo
echo '#undef USAGE'
echo '#undef dieusage'
@@ -52,27 +52,13 @@ cat <