From a85a79ef4b0c8634e9c261aba4a8e3dcbc443322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Sun, 15 Apr 2018 22:47:18 +0200 Subject: [PATCH 01/54] Better formatting --- README | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/README b/README index a5b54e1..53ba8dc 100644 --- a/README +++ b/README @@ -5,35 +5,44 @@ Useful shell scripts How to use: + The scripts are documented with their own manuals. The same manuals are also available as plain text and Markdown in the "doc" directory of the source distribution. These will also be installed in "/share/doc/shell-toolbox" by default. How to install: + Please see the document called "INSTALL" in the source distribution. Tested on: - OpenBSD 6.3, NetBSD 7.1.2, Darwin 17.5.0 (macOS High Sierra), - Ubuntu 17.10, Solaris 11.4, CentOS 7 + + CentOS 7 + Darwin 17.5.0 (macOS High Sierra) + NetBSD 7.1.2 + OpenBSD 6.3 + Solaris 11.4 + Ubuntu 17.10 ------------------------------------------------------------------------ # Shell scripts ------------------------------------------------------------------------ -* shell: Creates a shell for testing things in. +* shell: + + Creates a shell for testing things in. - This script is useful for testing things in an interactive - environment other than your usual shell, or for testing things in a - clean environment with automatic cleanup of any files left behind. + This script is useful for testing things in an interactive + environment other than your usual shell, or for testing things in a + clean environment with automatic cleanup of any files left behind. - Creates a "temporary interactive shell" with a temporary working - directory (unless the "-d" flag is used to specify an existing - directory) and clean environment. The working directory is removed - when the shell exits (unless the "-k" or "-d" flag was used). + Creates a "temporary interactive shell" with a temporary working + directory (unless the "-d" flag is used to specify an existing + directory) and clean environment. The working directory is removed + when the shell exits (unless the "-k" or "-d" flag was used). - The temporary working directory may also be pre-populated with the - contents of an existing directory (using the "-s" flag). + The temporary working directory may also be pre-populated with the + contents of an existing directory (using the "-s" flag). - See "man 1 shell" after installation. + See "man 1 shell" after installation. From e33adcb63d06d104fc9e0bcf60b2d6df67e2549d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Tue, 17 Apr 2018 12:51:31 +0200 Subject: [PATCH 02/54] Add test for mktemp and for whether its -t option adds a template --- configure.ac | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/configure.ac b/configure.ac index c057f8e..9d04916 100644 --- a/configure.ac +++ b/configure.ac @@ -8,6 +8,20 @@ AM_MAINTAINER_MODE AC_CONFIG_SRCDIR([src/shell.in]) +AC_PATH_PROG(MKTEMP, [mktemp]) +AS_IF([test -z "$MKTEMP"], [AC_MSG_ERROR([mktemp is missing, can not continue])]) + +# Test whether mktemp -t adds .XXXXXXXX to the filename template or not +AC_MSG_CHECKING([whether $MKTEMP -t adds .XXXXXXXX to template]) +_tmppath=$( "$MKTEMP" -t template.XXXXXXXX ) +_tmpname=${_tmppath##*/} +AS_IF([test "${_tmpname#template.XXXXXXXX}" = "$_tmpname"], + [AC_MSG_RESULT([no]); MKTEMP_TEMPLATE=".XXXXXXXX"], + [AC_MSG_RESULT([yes]); MKTEMP_TEMPLATE=""]) +rm -f "$_tmppath" +unset _tmppath _tmpname +AC_SUBST([MKTEMP_TEMPLATE]) + # "mandoc" and "col" are used for generating the manuals. These are only # needed if the distributed manuals are deleted with "make distclean". AC_PATH_PROG(MANDOC, [mandoc]) From f50cf69a52d7c67e5e20b5adf2b56ace6a08b630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Tue, 17 Apr 2018 12:52:33 +0200 Subject: [PATCH 03/54] Use variables set by configure --- src/shell.in | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/shell.in b/src/shell.in index 58dc569..30da96c 100644 --- a/src/shell.in +++ b/src/shell.in @@ -3,6 +3,10 @@ # Part of @PACKAGE_STRING@ # For bug reports, see "@PACKAGE_BUGREPORT@" +# Variables set by the configure script: +MKTEMP="@MKTEMP@" +MKTEMP_TEMPLATE="@MKTEMP_TEMPLATE@" + _error () { # Simple function for outputting error messages. Prefixes the error @@ -132,15 +136,8 @@ else fi if [ -z "$tmpwd" ]; then - # mktemp(1) on Darwin 17.5.0 (macOS) and NetBSD 7.1.2 adds - # '.XXXXXXXX' to the template when using "mktemp -t". - - template="shell-${shell##*/}" - case "$( uname )" in - Darwin|NetBSD) ;; - *) template="$template.XXXXXXXX" - esac - tmpwd="$( mktemp -d -t "$template" )" + template="shell-${shell##*/}$MKTEMP_TEMPLATE" + tmpwd="$( "$MKTEMP" -d -t "$template" )" elif [ ! -d "$tmpwd" ]; then if [ -e "$tmpwd" ]; then _error '"%s" exists, but is not a directory\n' "$tmpwd" From ebcd220a0fd4b30189914b0ce8f91afcd3601193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Tue, 17 Apr 2018 12:53:32 +0200 Subject: [PATCH 04/54] regen --- Makefile.in | 2 ++ configure | 69 +++++++++++++++++++++++++++++++++++++++++++++++++ doc/Makefile.in | 2 ++ src/Makefile.in | 2 ++ 4 files changed, 75 insertions(+) diff --git a/Makefile.in b/Makefile.in index 6c4eb9b..c2d7ef1 100644 --- a/Makefile.in +++ b/Makefile.in @@ -223,6 +223,8 @@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANDOC = @MANDOC@ MKDIR_P = @MKDIR_P@ +MKTEMP = @MKTEMP@ +MKTEMP_TEMPLATE = @MKTEMP_TEMPLATE@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ diff --git a/configure b/configure index 0bb69f8..08e1647 100755 --- a/configure +++ b/configure @@ -575,6 +575,8 @@ ac_subst_vars='LTLIBOBJS LIBOBJS COL MANDOC +MKTEMP_TEMPLATE +MKTEMP MAINT MAINTAINER_MODE_FALSE MAINTAINER_MODE_TRUE @@ -2388,6 +2390,73 @@ fi +# Extract the first word of "mktemp", so it can be a program name with args. +set dummy mktemp; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_path_MKTEMP+y} +then : + printf %s "(cached) " >&6 +else + case $MKTEMP in + [\\/]* | ?:[\\/]*) + ac_cv_path_MKTEMP="$MKTEMP" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_path_MKTEMP="$as_dir$ac_word$ac_exec_ext" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +MKTEMP=$ac_cv_path_MKTEMP +if test -n "$MKTEMP"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MKTEMP" >&5 +printf "%s\n" "$MKTEMP" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +if test -z "$MKTEMP" +then : + as_fn_error $? "mktemp is missing, can not continue" "$LINENO" 5 +fi + +# Test whether mktemp -t adds .XXXXXXXX to the filename template or not +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $MKTEMP -t adds .XXXXXXXX to template" >&5 +printf %s "checking whether $MKTEMP -t adds .XXXXXXXX to template... " >&6; } +_tmppath=$( "$MKTEMP" -t template.XXXXXXXX ) +_tmpname=${_tmppath##*/} +if test "${_tmpname#template.XXXXXXXX}" = "$_tmpname" +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; }; MKTEMP_TEMPLATE=".XXXXXXXX" +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; }; MKTEMP_TEMPLATE="" +fi +rm -f "$_tmppath" +unset _tmppath _tmpname + + # "mandoc" and "col" are used for generating the manuals. These are only # needed if the distributed manuals are deleted with "make distclean". # Extract the first word of "mandoc", so it can be a program name with args. diff --git a/doc/Makefile.in b/doc/Makefile.in index d09fc9a..e21837f 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -175,6 +175,8 @@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANDOC = @MANDOC@ MKDIR_P = @MKDIR_P@ +MKTEMP = @MKTEMP@ +MKTEMP_TEMPLATE = @MKTEMP_TEMPLATE@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ diff --git a/src/Makefile.in b/src/Makefile.in index 80b4e44..96c9de4 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -171,6 +171,8 @@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANDOC = @MANDOC@ MKDIR_P = @MKDIR_P@ +MKTEMP = @MKTEMP@ +MKTEMP_TEMPLATE = @MKTEMP_TEMPLATE@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ From d0a67cdf359a4627ae03f7be0219f5fdecc69110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Tue, 17 Apr 2018 13:20:35 +0200 Subject: [PATCH 05/54] Comment fixes --- configure.ac | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 9d04916..2b5bcc4 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,8 @@ AC_CONFIG_SRCDIR([src/shell.in]) AC_PATH_PROG(MKTEMP, [mktemp]) AS_IF([test -z "$MKTEMP"], [AC_MSG_ERROR([mktemp is missing, can not continue])]) -# Test whether mktemp -t adds .XXXXXXXX to the filename template or not +# Test whether "mktemp -t" adds .XXXXXXXX to the filename template or not. +# This is better than testing with "uname" in the src/shell.in script. AC_MSG_CHECKING([whether $MKTEMP -t adds .XXXXXXXX to template]) _tmppath=$( "$MKTEMP" -t template.XXXXXXXX ) _tmpname=${_tmppath##*/} @@ -23,7 +24,7 @@ unset _tmppath _tmpname AC_SUBST([MKTEMP_TEMPLATE]) # "mandoc" and "col" are used for generating the manuals. These are only -# needed if the distributed manuals are deleted with "make distclean". +# needed if the distributed manuals are ever deleted with "make distclean". AC_PATH_PROG(MANDOC, [mandoc]) AC_PATH_PROG(COL, [col]) AS_IF([test -z "$MANDOC" || test -z "$COL"], From ff013e12cf3c24221df6030801c98e9552027554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Tue, 17 Apr 2018 13:20:56 +0200 Subject: [PATCH 06/54] regen --- configure | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 08e1647..c7a680a 100755 --- a/configure +++ b/configure @@ -2440,7 +2440,8 @@ then : as_fn_error $? "mktemp is missing, can not continue" "$LINENO" 5 fi -# Test whether mktemp -t adds .XXXXXXXX to the filename template or not +# Test whether "mktemp -t" adds .XXXXXXXX to the filename template or not. +# This is better than testing with "uname" in the src/shell.in script. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $MKTEMP -t adds .XXXXXXXX to template" >&5 printf %s "checking whether $MKTEMP -t adds .XXXXXXXX to template... " >&6; } _tmppath=$( "$MKTEMP" -t template.XXXXXXXX ) @@ -2458,7 +2459,7 @@ unset _tmppath _tmpname # "mandoc" and "col" are used for generating the manuals. These are only -# needed if the distributed manuals are deleted with "make distclean". +# needed if the distributed manuals are ever deleted with "make distclean". # Extract the first word of "mandoc", so it can be a program name with args. set dummy mandoc; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 From 9c19ebe83f482e56464a3088aabb83463f5927ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Tue, 17 Apr 2018 14:34:49 +0200 Subject: [PATCH 07/54] Test whether mandoc can produce markdown output --- configure.ac | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/configure.ac b/configure.ac index 2b5bcc4..93fdbfa 100644 --- a/configure.ac +++ b/configure.ac @@ -30,6 +30,14 @@ AC_PATH_PROG(COL, [col]) AS_IF([test -z "$MANDOC" || test -z "$COL"], [AC_MSG_WARN([mandoc and/or col is missing, manuals can not be rebuilt after "make distclean"])]) +# Test whether "mandoc -T markdown" works. +AS_IF([test -n "$MANDOC" && test -n "$COL"], + [AC_MSG_CHECKING([whether $MANDOC can produce markdown output]) + AS_IF(["$MANDOC" -T markdown Date: Tue, 17 Apr 2018 14:37:02 +0200 Subject: [PATCH 08/54] Fixes * Create markdown document only if mandoc supports it * Don't fail make if we can't create documentation * Don't remove generated documentation with "make distclean" --- doc/Makefile.am | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/doc/Makefile.am b/doc/Makefile.am index a39fc16..b5ca999 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,16 +1,18 @@ dist_man1_MANS= shell.man dist_doc_DATA= shell.md shell.txt EXTRA_DIST= shell.mdoc -DISTCLEANFILES= shell.man shell.md shell.txt shell.man: $(srcdir)/shell.mdoc - test -x "$(MANDOC)" && \ - $(MANDOC) -T man -I os=Unix $(srcdir)/shell.mdoc >shell.man + test -n "$(MANDOC)" && \ + $(MANDOC) -T man -I os=Unix $(srcdir)/shell.mdoc >shell.man || true shell.md: $(srcdir)/shell.mdoc - test -x "$(MANDOC)" && \ - $(MANDOC) -T markdown -I os=Unix $(srcdir)/shell.mdoc >shell.md + test -n "$(MANDOC)" && \ + test "$(MANDOC_DOES_MARKDOWN)" -eq 1 && \ + $(MANDOC) -T markdown -I os=Unix $(srcdir)/shell.mdoc >shell.md || true shell.txt: $(srcdir)/shell.mdoc - test -x "$(MANDOC)" && test -x "$(COL)" && \ - $(MANDOC) -T ascii -I os=Unix $(srcdir)/shell.mdoc | $(COL) -b >shell.txt + test -n "$(MANDOC)" && \ + test -n "$(COL)" && \ + $(MANDOC) -T ascii -I os=Unix $(srcdir)/shell.mdoc | \ + $(COL) -b >shell.txt || true From b12aea7dcba1026ca2fa75b982b895ce5df08182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Tue, 17 Apr 2018 14:39:21 +0200 Subject: [PATCH 09/54] regen --- Makefile.in | 1 + configure | 17 +++++++++++++++++ doc/Makefile.in | 18 ++++++++++-------- src/Makefile.in | 1 + 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/Makefile.in b/Makefile.in index c2d7ef1..8cb1a78 100644 --- a/Makefile.in +++ b/Makefile.in @@ -222,6 +222,7 @@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANDOC = @MANDOC@ +MANDOC_DOES_MARKDOWN = @MANDOC_DOES_MARKDOWN@ MKDIR_P = @MKDIR_P@ MKTEMP = @MKTEMP@ MKTEMP_TEMPLATE = @MKTEMP_TEMPLATE@ diff --git a/configure b/configure index c7a680a..f48c843 100755 --- a/configure +++ b/configure @@ -573,6 +573,7 @@ PACKAGE_URL='' ac_unique_file="src/shell.in" ac_subst_vars='LTLIBOBJS LIBOBJS +MANDOC_DOES_MARKDOWN COL MANDOC MKTEMP_TEMPLATE @@ -2556,6 +2557,22 @@ then : printf "%s\n" "$as_me: WARNING: mandoc and/or col is missing, manuals can not be rebuilt after \"make distclean\"" >&2;} fi +# Test whether "mandoc -T markdown" works. +if test -n "$MANDOC" && test -n "$COL" +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $MANDOC can produce markdown output" >&5 +printf %s "checking whether $MANDOC can produce markdown output... " >&6; } + if "$MANDOC" -T markdown &5 +printf "%s\n" "yes" >&6; }; MANDOC_DOES_MARKDOWN=1 +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; }; MANDOC_DOES_MARKDOWN=0 +fi + +fi + ac_config_files="$ac_config_files Makefile src/Makefile doc/Makefile" ac_config_files="$ac_config_files src/shell" diff --git a/doc/Makefile.in b/doc/Makefile.in index e21837f..188ffd7 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -174,6 +174,7 @@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANDOC = @MANDOC@ +MANDOC_DOES_MARKDOWN = @MANDOC_DOES_MARKDOWN@ MKDIR_P = @MKDIR_P@ MKTEMP = @MKTEMP@ MKTEMP_TEMPLATE = @MKTEMP_TEMPLATE@ @@ -232,7 +233,6 @@ top_srcdir = @top_srcdir@ dist_man1_MANS = shell.man dist_doc_DATA = shell.md shell.txt EXTRA_DIST = shell.mdoc -DISTCLEANFILES = shell.man shell.md shell.txt all: all-am .SUFFIXES: @@ -400,7 +400,6 @@ clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @@ -492,16 +491,19 @@ uninstall-man: uninstall-man1 shell.man: $(srcdir)/shell.mdoc - test -x "$(MANDOC)" && \ - $(MANDOC) -T man -I os=Unix $(srcdir)/shell.mdoc >shell.man + test -n "$(MANDOC)" && \ + $(MANDOC) -T man -I os=Unix $(srcdir)/shell.mdoc >shell.man || true shell.md: $(srcdir)/shell.mdoc - test -x "$(MANDOC)" && \ - $(MANDOC) -T markdown -I os=Unix $(srcdir)/shell.mdoc >shell.md + test -n "$(MANDOC)" && \ + test "$(MANDOC_DOES_MARKDOWN)" -eq 1 && \ + $(MANDOC) -T markdown -I os=Unix $(srcdir)/shell.mdoc >shell.md || true shell.txt: $(srcdir)/shell.mdoc - test -x "$(MANDOC)" && test -x "$(COL)" && \ - $(MANDOC) -T ascii -I os=Unix $(srcdir)/shell.mdoc | $(COL) -b >shell.txt + test -n "$(MANDOC)" && \ + test -n "$(COL)" && \ + $(MANDOC) -T ascii -I os=Unix $(srcdir)/shell.mdoc | \ + $(COL) -b >shell.txt || true # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/src/Makefile.in b/src/Makefile.in index 96c9de4..cb36513 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -170,6 +170,7 @@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANDOC = @MANDOC@ +MANDOC_DOES_MARKDOWN = @MANDOC_DOES_MARKDOWN@ MKDIR_P = @MKDIR_P@ MKTEMP = @MKTEMP@ MKTEMP_TEMPLATE = @MKTEMP_TEMPLATE@ From e0526ce622e7236efbd60f8c2497db3336de0e0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Tue, 17 Apr 2018 14:44:56 +0200 Subject: [PATCH 10/54] Comment fixes --- configure.ac | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 93fdbfa..a7a827f 100644 --- a/configure.ac +++ b/configure.ac @@ -23,12 +23,13 @@ rm -f "$_tmppath" unset _tmppath _tmpname AC_SUBST([MKTEMP_TEMPLATE]) -# "mandoc" and "col" are used for generating the manuals. These are only -# needed if the distributed manuals are ever deleted with "make distclean". +# "mandoc" and "col" are used for generating the manuals. These are +# only needed if the distributed manuals are ever deleted or if the +# source manual sources are updated. AC_PATH_PROG(MANDOC, [mandoc]) AC_PATH_PROG(COL, [col]) AS_IF([test -z "$MANDOC" || test -z "$COL"], - [AC_MSG_WARN([mandoc and/or col is missing, manuals can not be rebuilt after "make distclean"])]) + [AC_MSG_WARN([mandoc and/or col is missing, manuals can not be rebuilt])]) # Test whether "mandoc -T markdown" works. AS_IF([test -n "$MANDOC" && test -n "$COL"], From 709e9f1c8274af9219d153c2d62797d1e1484a9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Tue, 17 Apr 2018 14:45:13 +0200 Subject: [PATCH 11/54] regen --- configure | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/configure b/configure index f48c843..526e9c6 100755 --- a/configure +++ b/configure @@ -2459,8 +2459,9 @@ rm -f "$_tmppath" unset _tmppath _tmpname -# "mandoc" and "col" are used for generating the manuals. These are only -# needed if the distributed manuals are ever deleted with "make distclean". +# "mandoc" and "col" are used for generating the manuals. These are +# only needed if the distributed manuals are ever deleted or if the +# source manual sources are updated. # Extract the first word of "mandoc", so it can be a program name with args. set dummy mandoc; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 @@ -2553,8 +2554,8 @@ fi if test -z "$MANDOC" || test -z "$COL" then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: mandoc and/or col is missing, manuals can not be rebuilt after \"make distclean\"" >&5 -printf "%s\n" "$as_me: WARNING: mandoc and/or col is missing, manuals can not be rebuilt after \"make distclean\"" >&2;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: mandoc and/or col is missing, manuals can not be rebuilt" >&5 +printf "%s\n" "$as_me: WARNING: mandoc and/or col is missing, manuals can not be rebuilt" >&2;} fi # Test whether "mandoc -T markdown" works. From 126b064b524469b1560274c547b48b1683b99506 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Tue, 17 Apr 2018 18:18:49 +0200 Subject: [PATCH 12/54] Reorder tests and be smarter --- configure.ac | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index a7a827f..c419d6d 100644 --- a/configure.ac +++ b/configure.ac @@ -24,20 +24,17 @@ unset _tmppath _tmpname AC_SUBST([MKTEMP_TEMPLATE]) # "mandoc" and "col" are used for generating the manuals. These are -# only needed if the distributed manuals are ever deleted or if the -# source manual sources are updated. -AC_PATH_PROG(MANDOC, [mandoc]) +# only needed if the distributed manuals are ever deleted (e.g. using +# "make distclean") or if the source manual sources are updated. AC_PATH_PROG(COL, [col]) -AS_IF([test -z "$MANDOC" || test -z "$COL"], - [AC_MSG_WARN([mandoc and/or col is missing, manuals can not be rebuilt])]) - -# Test whether "mandoc -T markdown" works. -AS_IF([test -n "$MANDOC" && test -n "$COL"], +AC_PATH_PROG(MANDOC, [mandoc]) +AS_IF([test -n "$MANDOC"], [AC_MSG_CHECKING([whether $MANDOC can produce markdown output]) - AS_IF(["$MANDOC" -T markdown /dev/null], [AC_MSG_RESULT([yes]); MANDOC_DOES_MARKDOWN=1], [AC_MSG_RESULT([no]); MANDOC_DOES_MARKDOWN=0]) - AC_SUBST([MANDOC_DOES_MARKDOWN]) ]) + AC_SUBST([MANDOC_DOES_MARKDOWN])], + [AC_MSG_WARN([mandoc is missing, manuals can not be rebuilt]) ]) AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile]) AC_CONFIG_FILES([src/shell], [chmod +x src/shell]) From c3cb7ba33d0979186043ddc048caf14b82a40d55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Tue, 17 Apr 2018 18:19:30 +0200 Subject: [PATCH 13/54] Revert removing DISTCLEANFILES --- doc/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/Makefile.am b/doc/Makefile.am index b5ca999..1b9fbf9 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,6 +1,7 @@ dist_man1_MANS= shell.man dist_doc_DATA= shell.md shell.txt EXTRA_DIST= shell.mdoc +DISTCLEANFILES= shell.man shell.md shell.txt shell.man: $(srcdir)/shell.mdoc test -n "$(MANDOC)" && \ From 6574846fe40174cf1b9bb5bd7ea4c52e70caa041 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Tue, 17 Apr 2018 18:20:31 +0200 Subject: [PATCH 14/54] regen --- configure | 60 +++++++++++++++++++++++-------------------------- doc/Makefile.in | 2 ++ 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/configure b/configure index 526e9c6..454a18c 100755 --- a/configure +++ b/configure @@ -574,8 +574,8 @@ ac_unique_file="src/shell.in" ac_subst_vars='LTLIBOBJS LIBOBJS MANDOC_DOES_MARKDOWN -COL MANDOC +COL MKTEMP_TEMPLATE MKTEMP MAINT @@ -2460,19 +2460,19 @@ unset _tmppath _tmpname # "mandoc" and "col" are used for generating the manuals. These are -# only needed if the distributed manuals are ever deleted or if the -# source manual sources are updated. -# Extract the first word of "mandoc", so it can be a program name with args. -set dummy mandoc; ac_word=$2 +# only needed if the distributed manuals are ever deleted (e.g. using +# "make distclean") or if the source manual sources are updated. +# Extract the first word of "col", so it can be a program name with args. +set dummy col; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_path_MANDOC+y} +if test ${ac_cv_path_COL+y} then : printf %s "(cached) " >&6 else - case $MANDOC in + case $COL in [\\/]* | ?:[\\/]*) - ac_cv_path_MANDOC="$MANDOC" # Let the user override the test with a path. + ac_cv_path_COL="$COL" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -2486,7 +2486,7 @@ do esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_path_MANDOC="$as_dir$ac_word$ac_exec_ext" + ac_cv_path_COL="$as_dir$ac_word$ac_exec_ext" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi @@ -2497,27 +2497,27 @@ IFS=$as_save_IFS ;; esac fi -MANDOC=$ac_cv_path_MANDOC -if test -n "$MANDOC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MANDOC" >&5 -printf "%s\n" "$MANDOC" >&6; } +COL=$ac_cv_path_COL +if test -n "$COL"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $COL" >&5 +printf "%s\n" "$COL" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi -# Extract the first word of "col", so it can be a program name with args. -set dummy col; ac_word=$2 +# Extract the first word of "mandoc", so it can be a program name with args. +set dummy mandoc; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_path_COL+y} +if test ${ac_cv_path_MANDOC+y} then : printf %s "(cached) " >&6 else - case $COL in + case $MANDOC in [\\/]* | ?:[\\/]*) - ac_cv_path_COL="$COL" # Let the user override the test with a path. + ac_cv_path_MANDOC="$MANDOC" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -2531,7 +2531,7 @@ do esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_path_COL="$as_dir$ac_word$ac_exec_ext" + ac_cv_path_MANDOC="$as_dir$ac_word$ac_exec_ext" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi @@ -2542,28 +2542,21 @@ IFS=$as_save_IFS ;; esac fi -COL=$ac_cv_path_COL -if test -n "$COL"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $COL" >&5 -printf "%s\n" "$COL" >&6; } +MANDOC=$ac_cv_path_MANDOC +if test -n "$MANDOC"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MANDOC" >&5 +printf "%s\n" "$MANDOC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi -if test -z "$MANDOC" || test -z "$COL" -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: mandoc and/or col is missing, manuals can not be rebuilt" >&5 -printf "%s\n" "$as_me: WARNING: mandoc and/or col is missing, manuals can not be rebuilt" >&2;} -fi - -# Test whether "mandoc -T markdown" works. -if test -n "$MANDOC" && test -n "$COL" +if test -n "$MANDOC" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $MANDOC can produce markdown output" >&5 printf %s "checking whether $MANDOC can produce markdown output... " >&6; } - if "$MANDOC" -T markdown /dev/null then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; }; MANDOC_DOES_MARKDOWN=1 @@ -2572,6 +2565,9 @@ else printf "%s\n" "no" >&6; }; MANDOC_DOES_MARKDOWN=0 fi +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: mandoc is missing, manuals can not be rebuilt" >&5 +printf "%s\n" "$as_me: WARNING: mandoc is missing, manuals can not be rebuilt" >&2;} fi ac_config_files="$ac_config_files Makefile src/Makefile doc/Makefile" diff --git a/doc/Makefile.in b/doc/Makefile.in index 188ffd7..b36deb7 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -233,6 +233,7 @@ top_srcdir = @top_srcdir@ dist_man1_MANS = shell.man dist_doc_DATA = shell.md shell.txt EXTRA_DIST = shell.mdoc +DISTCLEANFILES = shell.man shell.md shell.txt all: all-am .SUFFIXES: @@ -400,6 +401,7 @@ clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" From a9bfe5bc4700ccc8e84bbb6381ae9afd81322690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Wed, 18 Apr 2018 09:45:44 +0200 Subject: [PATCH 15/54] Smarter --- configure.ac | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/configure.ac b/configure.ac index c419d6d..9ba224c 100644 --- a/configure.ac +++ b/configure.ac @@ -8,24 +8,28 @@ AM_MAINTAINER_MODE AC_CONFIG_SRCDIR([src/shell.in]) +# Test whether mktemp exists, and if it does, whether "mktemp -t" adds +# .XXXXXXXX to the filename template or not. This is better than +# testing with "uname" in the src/shell.in script. AC_PATH_PROG(MKTEMP, [mktemp]) -AS_IF([test -z "$MKTEMP"], [AC_MSG_ERROR([mktemp is missing, can not continue])]) +AS_IF([test -n "$MKTEMP"], + [AC_MSG_CHECKING([whether $MKTEMP -t adds .XXXXXXXX to template]) + _tmppath=$( "$MKTEMP" -t template.XXXXXXXX ) + _tmpname=${_tmppath##*/} + AS_IF([test "${_tmpname#template.XXXXXXXX}" = "$_tmpname"], + [AC_MSG_RESULT([no]); MKTEMP_TEMPLATE=".XXXXXXXX"], + [AC_MSG_RESULT([yes]); MKTEMP_TEMPLATE=""]) + rm -f "$_tmppath" + unset -v _tmppath + unset -v _tmpname + AC_SUBST([MKTEMP_TEMPLATE])], + [AC_MSG_ERROR([mktemp is missing, can not continue]) ]) -# Test whether "mktemp -t" adds .XXXXXXXX to the filename template or not. -# This is better than testing with "uname" in the src/shell.in script. -AC_MSG_CHECKING([whether $MKTEMP -t adds .XXXXXXXX to template]) -_tmppath=$( "$MKTEMP" -t template.XXXXXXXX ) -_tmpname=${_tmppath##*/} -AS_IF([test "${_tmpname#template.XXXXXXXX}" = "$_tmpname"], - [AC_MSG_RESULT([no]); MKTEMP_TEMPLATE=".XXXXXXXX"], - [AC_MSG_RESULT([yes]); MKTEMP_TEMPLATE=""]) -rm -f "$_tmppath" -unset _tmppath _tmpname -AC_SUBST([MKTEMP_TEMPLATE]) -# "mandoc" and "col" are used for generating the manuals. These are -# only needed if the distributed manuals are ever deleted (e.g. using -# "make distclean") or if the source manual sources are updated. +# mandoc is used for generating the manuals. It's only needed if the +# distributed manuals are ever deleted (e.g. using "make distclean") or +# if the source manual sources are updated. col is used for generating +# the text-only version of the manuals. AC_PATH_PROG(COL, [col]) AC_PATH_PROG(MANDOC, [mandoc]) AS_IF([test -n "$MANDOC"], From abdffe0bb5fe51d01f5a00d2341f2b3ba170b534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Wed, 18 Apr 2018 09:46:02 +0200 Subject: [PATCH 16/54] regen --- configure | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/configure b/configure index 454a18c..95be3e0 100755 --- a/configure +++ b/configure @@ -2391,6 +2391,9 @@ fi +# Test whether mktemp exists, and if it does, whether "mktemp -t" adds +# .XXXXXXXX to the filename template or not. This is better than +# testing with "uname" in the src/shell.in script. # Extract the first word of "mktemp", so it can be a program name with args. set dummy mktemp; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 @@ -2436,18 +2439,13 @@ printf "%s\n" "no" >&6; } fi -if test -z "$MKTEMP" +if test -n "$MKTEMP" then : - as_fn_error $? "mktemp is missing, can not continue" "$LINENO" 5 -fi - -# Test whether "mktemp -t" adds .XXXXXXXX to the filename template or not. -# This is better than testing with "uname" in the src/shell.in script. -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $MKTEMP -t adds .XXXXXXXX to template" >&5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $MKTEMP -t adds .XXXXXXXX to template" >&5 printf %s "checking whether $MKTEMP -t adds .XXXXXXXX to template... " >&6; } -_tmppath=$( "$MKTEMP" -t template.XXXXXXXX ) -_tmpname=${_tmppath##*/} -if test "${_tmpname#template.XXXXXXXX}" = "$_tmpname" + _tmppath=$( "$MKTEMP" -t template.XXXXXXXX ) + _tmpname=${_tmppath##*/} + if test "${_tmpname#template.XXXXXXXX}" = "$_tmpname" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; }; MKTEMP_TEMPLATE=".XXXXXXXX" @@ -2455,8 +2453,13 @@ else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; }; MKTEMP_TEMPLATE="" fi -rm -f "$_tmppath" -unset _tmppath _tmpname + rm -f "$_tmppath" + unset -v _tmppath + unset -v _tmpname + +else + as_fn_error $? "mktemp is missing, can not continue" "$LINENO" 5 +fi # "mandoc" and "col" are used for generating the manuals. These are From 4a51a25eb28d8b45821717c8480bdd3f0107a454 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Wed, 18 Apr 2018 11:26:38 +0200 Subject: [PATCH 17/54] Smarter --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 9ba224c..96d6074 100644 --- a/configure.ac +++ b/configure.ac @@ -25,7 +25,6 @@ AS_IF([test -n "$MKTEMP"], AC_SUBST([MKTEMP_TEMPLATE])], [AC_MSG_ERROR([mktemp is missing, can not continue]) ]) - # mandoc is used for generating the manuals. It's only needed if the # distributed manuals are ever deleted (e.g. using "make distclean") or # if the source manual sources are updated. col is used for generating @@ -35,8 +34,9 @@ AC_PATH_PROG(MANDOC, [mandoc]) AS_IF([test -n "$MANDOC"], [AC_MSG_CHECKING([whether $MANDOC can produce markdown output]) AS_IF(["$MANDOC" -T markdown /dev/null], - [AC_MSG_RESULT([yes]); MANDOC_DOES_MARKDOWN=1], - [AC_MSG_RESULT([no]); MANDOC_DOES_MARKDOWN=0]) + [MANDOC_DOES_MARKDOWN=yes], + [MANDOC_DOES_MARKDOWN=no]) + AC_MSG_RESULT([$MANDOC_DOES_MARKDOWN]) AC_SUBST([MANDOC_DOES_MARKDOWN])], [AC_MSG_WARN([mandoc is missing, manuals can not be rebuilt]) ]) From a18c676abcf362c01daa819469f6d4011b23097c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Wed, 18 Apr 2018 11:27:24 +0200 Subject: [PATCH 18/54] Goes with previous commit to configure.ac --- doc/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Makefile.am b/doc/Makefile.am index 1b9fbf9..11a5a2f 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -9,7 +9,7 @@ shell.man: $(srcdir)/shell.mdoc shell.md: $(srcdir)/shell.mdoc test -n "$(MANDOC)" && \ - test "$(MANDOC_DOES_MARKDOWN)" -eq 1 && \ + test "$(MANDOC_DOES_MARKDOWN)" = "yes" && \ $(MANDOC) -T markdown -I os=Unix $(srcdir)/shell.mdoc >shell.md || true shell.txt: $(srcdir)/shell.mdoc From cbb32b9da61e16e530018e146b630a308eb3ce43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Wed, 18 Apr 2018 11:27:53 +0200 Subject: [PATCH 19/54] Add -v option for version information --- src/shell.in | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/shell.in b/src/shell.in index 30da96c..f6f8174 100644 --- a/src/shell.in +++ b/src/shell.in @@ -87,13 +87,17 @@ get_shells () force=0 # when 1, bypasses the call to get_shells keep=0 # when 1, does not remove working directory when exiting -while getopts 'd:fks:' opt; do +while getopts 'd:fks:v' opt; do case "$opt" in d) tmpwd=$OPTARG keep=1 ;; f) force=1 ;; k) keep=1 ;; s) skel=$OPTARG ;; + v) printf 'shell: part of %s (release "%s")\n' \ + "@PACKAGE_NAME@" "@PACKAGE_VERSION@" + printf 'For bug reports, see %s\n' "@PACKAGE_BUGREPORT@" + exit 0 ;; *) _error 'error while parsing the command line\n' exit 1 esac From 20dfd10cacaf7591a154caecf42d4757637d2ee0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Wed, 18 Apr 2018 11:28:27 +0200 Subject: [PATCH 20/54] Document new -v option, and various other minor fixes --- doc/shell.mdoc | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/doc/shell.mdoc b/doc/shell.mdoc index e3ba627..b31687a 100644 --- a/doc/shell.mdoc +++ b/doc/shell.mdoc @@ -14,6 +14,8 @@ .Op Fl s Ar directory .Op Fl k .Op Ar shell Op Ar ... +.Nm +.Fl v .Sh DESCRIPTION The .Nm @@ -38,6 +40,9 @@ or .Ev $SHELL , against the basenames of the allowed login shells). +This behaviour may be bypassed by using the +.Fl f +command line option. .Pp Any operands present after the name of the .Ar shell @@ -67,6 +72,8 @@ directory to the temporary working directory. This option conflicts with the .Fl d option. +.It Fl v +Output version information and immediately terminate. .El .Sh ENVIRONMENT .Nm @@ -107,7 +114,9 @@ Set to the absolute path of the real shell executable. This may be different from the .Ar shell mentioned on the command line as the actual shell used will always be -picked from the list of valid login shells. +picked from the list of valid login shells (unless +.Fl f +is used). .It Ev TERM Carried over from the parent environment. .El @@ -151,15 +160,15 @@ Start .Cm ksh as a login shell and pre-populate the temporary directory with the contents of -.Pa /etc/skel . +.Pa $HOME/skel . Note, starting the .Cm ksh -shell as a login shell will make it execute the +shell as a login shell will in this case make it execute the .Pa .profile file copied from -.Pa /etc/skel . +.Pa $HOME/skel . .Bd -literal -offset Ds -$ shell -s /etc/skel ksh -l +$ shell -s "$HOME/skel" ksh -l Starting /bin/ksh in /tmp/shell-ksh.4DzEG6qr $ ls -la total 16 From bf4291729b6b230f5609a9ad2d13fb12643cc28e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Wed, 18 Apr 2018 11:29:07 +0200 Subject: [PATCH 21/54] Append "post-" to version number when on "develop" branch --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 96d6074..da469b1 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.69]) -AC_INIT([shell-toolbox],[20180415],[https://github.com/kusalananda/shell-toolbox/issues]) +AC_INIT([shell-toolbox],[post-20180415],[https://github.com/kusalananda/shell-toolbox/issues]) AC_CONFIG_AUX_DIR([build]) From aa97ea607923b038619f4786f4b570ff47032ec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Wed, 18 Apr 2018 11:29:52 +0200 Subject: [PATCH 22/54] regen --- configure | 36 ++++++++++++++++++------------------ doc/Makefile.in | 2 +- doc/shell.man | 24 ++++++++++++++++++------ doc/shell.md | 25 ++++++++++++++++++------- doc/shell.txt | 17 +++++++++++------ 5 files changed, 66 insertions(+), 38 deletions(-) diff --git a/configure b/configure index 95be3e0..da4751a 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69.195-487d6 for shell-toolbox 20180415. +# Generated by GNU Autoconf 2.69.195-487d6 for shell-toolbox post-20180415. # # Report bugs to . # @@ -565,8 +565,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='shell-toolbox' PACKAGE_TARNAME='shell-toolbox' -PACKAGE_VERSION='20180415' -PACKAGE_STRING='shell-toolbox 20180415' +PACKAGE_VERSION='post-20180415' +PACKAGE_STRING='shell-toolbox post-20180415' PACKAGE_BUGREPORT='https://github.com/kusalananda/shell-toolbox/issues' PACKAGE_URL='' @@ -1206,7 +1206,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures shell-toolbox 20180415 to adapt to many kinds of systems. +\`configure' configures shell-toolbox post-20180415 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1273,7 +1273,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of shell-toolbox 20180415:";; + short | recursive ) echo "Configuration of shell-toolbox post-20180415:";; esac cat <<\_ACEOF @@ -1350,7 +1350,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -shell-toolbox configure 20180415 +shell-toolbox configure post-20180415 generated by GNU Autoconf 2.69.195-487d6 Copyright (C) 2017 Free Software Foundation, Inc. @@ -1387,7 +1387,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by shell-toolbox $as_me 20180415, which was +It was created by shell-toolbox $as_me post-20180415, which was generated by GNU Autoconf 2.69.195-487d6. Invocation command line was $ $0$ac_configure_args_raw @@ -2275,7 +2275,7 @@ fi # Define the identity of the package. PACKAGE='shell-toolbox' - VERSION='20180415' + VERSION='post-20180415' printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h @@ -2461,10 +2461,10 @@ else as_fn_error $? "mktemp is missing, can not continue" "$LINENO" 5 fi - -# "mandoc" and "col" are used for generating the manuals. These are -# only needed if the distributed manuals are ever deleted (e.g. using -# "make distclean") or if the source manual sources are updated. +# mandoc is used for generating the manuals. It's only needed if the +# distributed manuals are ever deleted (e.g. using "make distclean") or +# if the source manual sources are updated. col is used for generating +# the text-only version of the manuals. # Extract the first word of "col", so it can be a program name with args. set dummy col; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 @@ -2561,12 +2561,12 @@ then : printf %s "checking whether $MANDOC can produce markdown output... " >&6; } if "$MANDOC" -T markdown /dev/null then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; }; MANDOC_DOES_MARKDOWN=1 + MANDOC_DOES_MARKDOWN=yes else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; }; MANDOC_DOES_MARKDOWN=0 + MANDOC_DOES_MARKDOWN=no fi + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MANDOC_DOES_MARKDOWN" >&5 +printf "%s\n" "$MANDOC_DOES_MARKDOWN" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: mandoc is missing, manuals can not be rebuilt" >&5 @@ -3104,7 +3104,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by shell-toolbox $as_me 20180415, which was +This file was extended by shell-toolbox $as_me post-20180415, which was generated by GNU Autoconf 2.69.195-487d6. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -3159,7 +3159,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ -shell-toolbox config.status 20180415 +shell-toolbox config.status post-20180415 configured by $0, generated by GNU Autoconf 2.69.195-487d6, with options \\"\$ac_cs_config\\" diff --git a/doc/Makefile.in b/doc/Makefile.in index b36deb7..7ceabb6 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -498,7 +498,7 @@ shell.man: $(srcdir)/shell.mdoc shell.md: $(srcdir)/shell.mdoc test -n "$(MANDOC)" && \ - test "$(MANDOC_DOES_MARKDOWN)" -eq 1 && \ + test "$(MANDOC_DOES_MARKDOWN)" = "yes" && \ $(MANDOC) -T markdown -I os=Unix $(srcdir)/shell.mdoc >shell.md || true shell.txt: $(srcdir)/shell.mdoc diff --git a/doc/shell.man b/doc/shell.man index 35ca952..7813c61 100644 --- a/doc/shell.man +++ b/doc/shell.man @@ -1,4 +1,4 @@ -.TH "SHELL" "1" "April 15, 2018" "Unix" "General Commands Manual" +.TH "SHELL" "1" "April 18, 2018" "Unix" "General Commands Manual" .nh .if n .ad l .SH "NAME" @@ -18,6 +18,10 @@ [\fB\-s\fR\ \fIdirectory\fR] [\fB\-k\fR] [\fIshell\fR\ [\fI...\fR]] +.br +.HP 6n +\fBshell\fR +\fB\-v\fR .PD .SH "DESCRIPTION" The @@ -43,6 +47,9 @@ or \fR$SHELL\fR, against the basenames of the allowed login shells). +This behaviour may be bypassed by using the +\fB\-f\fR +command line option. .PP Any operands present after the name of the \fIshell\fR @@ -75,6 +82,9 @@ directory to the temporary working directory. This option conflicts with the \fB\-d\fR option. +.TP 8n +\fB\-v\fR +Output version information and immediately terminate. .SH "ENVIRONMENT" \fBshell\fR uses the following environment variables: @@ -117,7 +127,9 @@ Set to the absolute path of the real shell executable. This may be different from the \fIshell\fR mentioned on the command line as the actual shell used will always be -picked from the list of valid login shells. +picked from the list of valid login shells (unless +\fB\-f\fR +is used). .TP 8n \fRTERM\fR Carried over from the parent environment. @@ -169,17 +181,17 @@ Start \fBksh\fR as a login shell and pre-populate the temporary directory with the contents of -\fI/etc/skel\fR. +\fI$HOME/skel\fR. Note, starting the \fBksh\fR -shell as a login shell will make it execute the +shell as a login shell will in this case make it execute the \fI.profile\fR file copied from -\fI/etc/skel\fR. +\fI$HOME/skel\fR. .nf .sp .RS 6n -$ shell -s /etc/skel ksh -l +$ shell -s "$HOME/skel" ksh -l Starting /bin/ksh in /tmp/shell-ksh.4DzEG6qr $ ls -la total 16 diff --git a/doc/shell.md b/doc/shell.md index 000d9d4..c22658d 100644 --- a/doc/shell.md +++ b/doc/shell.md @@ -14,7 +14,9 @@ SHELL(1) - General Commands Manual \[**-f**] \[**-s** *directory*] \[**-k**] -\[*shell* \[*...*]] +\[*shell* \[*...*]] +**shell** +**-v** # DESCRIPTION @@ -41,6 +43,9 @@ or `$SHELL`, against the basenames of the allowed login shells). +This behaviour may be bypassed by using the +**-f** +command line option. Any operands present after the name of the *shell* @@ -78,6 +83,10 @@ The options are as follows: > **-d** > option. +**-v** + +> Output version information and immediately terminate. + # ENVIRONMENT **shell** @@ -127,7 +136,9 @@ also sets the following environment variables: > This may be different from the > *shell* > mentioned on the command line as the actual shell used will always be -> picked from the list of valid login shells. +> picked from the list of valid login shells (unless +> **-f** +> is used). `TERM` @@ -172,15 +183,15 @@ Start **ksh** as a login shell and pre-populate the temporary directory with the contents of -*/etc/skel*. +*$HOME/skel*. Note, starting the **ksh** -shell as a login shell will make it execute the +shell as a login shell will in this case make it execute the *.profile* file copied from -*/etc/skel*. +*$HOME/skel*. - $ shell -s /etc/skel ksh -l + $ shell -s "$HOME/skel" ksh -l Starting /bin/ksh in /tmp/shell-ksh.4DzEG6qr $ ls -la total 16 @@ -217,4 +228,4 @@ The */etc/shells* file will still be used if it exists. -Unix - April 15, 2018 +Unix - April 18, 2018 diff --git a/doc/shell.txt b/doc/shell.txt index 4e854ea..10b23e5 100644 --- a/doc/shell.txt +++ b/doc/shell.txt @@ -7,6 +7,7 @@ NAME SYNOPSIS shell [-f] [-d directory | -k] [shell [...]] shell [-f] [-s directory] [-k] [shell [...]] + shell -v DESCRIPTION The shell utility creates an interactive shell session with a clean @@ -20,7 +21,8 @@ DESCRIPTION The basename of the named shell must correspond to a valid login shell and the actual shell that is started will always be taken from the list of valid login shells (by matching the basename of the specified shell, - or $SHELL, against the basenames of the allowed login shells). + or $SHELL, against the basenames of the allowed login shells). This + behaviour may be bypassed by using the -f command line option. Any operands present after the name of the shell will be passed as is to the shell in question. @@ -46,6 +48,8 @@ DESCRIPTION rooted in the specified directory to the temporary working directory. This option conflicts with the -d option. + -v Output version information and immediately terminate. + ENVIRONMENT shell uses the following environment variables: @@ -70,7 +74,7 @@ ENVIRONMENT SHELL Set to the absolute path of the real shell executable. This may be different from the shell mentioned on the command line as the actual shell used will always be picked from the list of valid - login shells. + login shells (unless -f is used). TERM Carried over from the parent environment. @@ -102,10 +106,11 @@ EXAMPLES Leaving /home/myself/testing in place Start ksh as a login shell and pre-populate the temporary directory with - the contents of /etc/skel. Note, starting the ksh shell as a login shell - will make it execute the .profile file copied from /etc/skel. + the contents of $HOME/skel. Note, starting the ksh shell as a login + shell will in this case make it execute the .profile file copied from + $HOME/skel. - $ shell -s /etc/skel ksh -l + $ shell -s "$HOME/skel" ksh -l Starting /bin/ksh in /tmp/shell-ksh.4DzEG6qr $ ls -la total 16 @@ -132,4 +137,4 @@ CAVEATS "getent shells" and may also lack the /etc/shells file. The /etc/shells file will still be used if it exists. -Unix April 15, 2018 Unix +Unix April 18, 2018 Unix From ea708ab811bdc95b8f8c80eae6018638739b8687 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Wed, 18 Apr 2018 18:40:38 +0200 Subject: [PATCH 23/54] Remove CentOS, add FreeBSD * Now tested on FreeBSD (works as intended), prompted by issue #3 ("Heads up: FreeBSD port is on its way"). * Removed CentOS as I don't have a VM to test in, and I'm unlikely to set one up at the moment. --- README | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README b/README index 53ba8dc..fa8d2fa 100644 --- a/README +++ b/README @@ -17,11 +17,11 @@ How to install: Tested on: - CentOS 7 + FreeBSD 11.1 Darwin 17.5.0 (macOS High Sierra) NetBSD 7.1.2 OpenBSD 6.3 - Solaris 11.4 + Solaris 11.4-beta Ubuntu 17.10 From 1ba59761b21ef7f608ead2e6e08cd01aee83fa88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Wed, 18 Apr 2018 20:45:08 +0200 Subject: [PATCH 24/54] Warning about "make distclean" and not having mandoc(1) --- INSTALL | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/INSTALL b/INSTALL index fcb8045..3013d99 100644 --- a/INSTALL +++ b/INSTALL @@ -24,3 +24,8 @@ To install using GNU Stow under "$HOME/local": stow shell-toolbox Then make sure that "$HOME/local/bin" is in your "$PATH". + + +Caveat: If you run "make distclean", the generated manuals, which are +part of the distribution sources, will be removed. These won't be +rebuilt unless you have mandoc(1) installed. From 00f4b271fb4ff210e4990ac65f8a6bcdddccddee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Wed, 18 Apr 2018 20:58:18 +0200 Subject: [PATCH 25/54] Correctly deal with directory names that may start with dash --- src/shell.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shell.in b/src/shell.in index f6f8174..723d4ba 100644 --- a/src/shell.in +++ b/src/shell.in @@ -167,7 +167,7 @@ if [ -n "$skel" ]; then fi if command -v pax >/dev/null 2>&1; then - ( cd "$skel" && pax -rw -p p . "$tmpwd" ) + ( cd -- "$skel" && pax -rw -p p . "$tmpwd" ) elif command -v tar >/dev/null 2>&1; then tar -cv -f - -C "$skel" . | tar -x -p -f - -C "$tmpwd" else @@ -178,7 +178,7 @@ fi printf 'Starting %s in %s\n' "$realshell" "$tmpwd" >&2 -cd "$tmpwd" && +cd -- "$tmpwd" && env -i HOME="$tmpwd" \ PATH="$( getconf PATH )" \ PS1='$ ' \ From dd2e9517df826e6b8a6426f341a5a21beef9f4db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Wed, 18 Apr 2018 21:49:51 +0200 Subject: [PATCH 26/54] First commit of NEWS file --- NEWS | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 NEWS diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..7579fb7 --- /dev/null +++ b/NEWS @@ -0,0 +1,23 @@ +Next release + * Added NEWS file. + * Added -v option to output version information. + * Let the configure script figure out whether "mktemp -t" adds + ".XXXXXXXX" to the end of the given template or not. + * Don't choke on directories whose name start with a dash. + * Now properly tested on FreeBSD 11.1. + +Release 20180415 + * Fixed GitHub issue #1, "Centos 7 several shells with the same name". + * Fixed GitHub issue #2, "Comparison null string to zero (int)" + * Added manual. + * Added -f option to force running the given command (bypasses check + for valid login shell). + * Added -s option for specifying a "skeleton" directory whose + contents will be (recursively) copied into the newly created + temporary directory. + * Updated static list of shells on Solaris with shells from the + shells(4) manual on a Solaris 11.4-beta system. + * Set HOME to the temporary directory. + +Release 20180401 + * First real release. From 80d8b0aa4267686595eac7e70b2255499ce6b44f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Wed, 18 Apr 2018 21:50:19 +0200 Subject: [PATCH 27/54] Install README, NEWS and LICENSE files too --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 7b6982b..6dec2d5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,2 +1,2 @@ SUBDIRS= src doc -EXTRA_DIST= LICENSE +dist_doc_DATA= LICENSE NEWS README From 399ef6482fc8604546b270a52710f4c76065fa40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Wed, 18 Apr 2018 21:52:16 +0200 Subject: [PATCH 28/54] regen --- Makefile.in | 81 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 68 insertions(+), 13 deletions(-) diff --git a/Makefile.in b/Makefile.in index 8cb1a78..f3a0481 100644 --- a/Makefile.in +++ b/Makefile.in @@ -13,6 +13,7 @@ # PARTICULAR PURPOSE. @SET_MAKE@ + VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ @@ -91,7 +92,7 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ - $(am__configure_deps) $(am__DIST_COMMON) + $(am__configure_deps) $(dist_doc_DATA) $(am__DIST_COMMON) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d @@ -124,6 +125,35 @@ am__can_run_installinfo = \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__installdirs = "$(DESTDIR)$(docdir)" +DATA = $(dist_doc_DATA) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ @@ -154,7 +184,7 @@ CTAGS = ctags CSCOPE = cscope DIST_SUBDIRS = $(SUBDIRS) am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/build/install-sh \ - $(top_srcdir)/build/missing INSTALL README TODO \ + $(top_srcdir)/build/missing INSTALL NEWS README TODO \ build/install-sh build/missing DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) @@ -279,7 +309,7 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = src doc -EXTRA_DIST = LICENSE +dist_doc_DATA = LICENSE NEWS README all: all-recursive .SUFFIXES: @@ -316,6 +346,27 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): +install-dist_docDATA: $(dist_doc_DATA) + @$(NORMAL_INSTALL) + @list='$(dist_doc_DATA)'; test -n "$(docdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(docdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(docdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(docdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(docdir)" || exit $$?; \ + done + +uninstall-dist_docDATA: + @$(NORMAL_UNINSTALL) + @list='$(dist_doc_DATA)'; test -n "$(docdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(docdir)'; $(am__uninstall_files_from_dir) # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. @@ -616,9 +667,12 @@ distcleancheck: distclean exit 1; } >&2 check-am: all-am check: check-recursive -all-am: Makefile +all-am: Makefile $(DATA) installdirs: installdirs-recursive installdirs-am: + for dir in "$(DESTDIR)$(docdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive @@ -670,7 +724,7 @@ info: info-recursive info-am: -install-data-am: +install-data-am: install-dist_docDATA install-dvi: install-dvi-recursive @@ -716,7 +770,7 @@ ps: ps-recursive ps-am: -uninstall-am: +uninstall-am: uninstall-dist_docDATA .MAKE: $(am__recursive_targets) install-am install-strip @@ -727,13 +781,14 @@ uninstall-am: distcheck distclean distclean-generic distclean-tags \ distcleancheck distdir distuninstallcheck dvi dvi-am html \ html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ - pdf-am ps ps-am tags tags-am uninstall uninstall-am + install-data-am install-dist_docDATA install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + installdirs-am maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-generic pdf pdf-am ps ps-am tags \ + tags-am uninstall uninstall-am uninstall-dist_docDATA .PRECIOUS: Makefile From 4e280e5124131b0a97bc273ca47498638feb4158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Thu, 19 Apr 2018 07:52:07 +0200 Subject: [PATCH 29/54] Various * Prefix all functions with underscore. * Make tar be quiet. * Informational message when copying skeleton directory. --- doc/shell.mdoc | 1 + src/shell.in | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/doc/shell.mdoc b/doc/shell.mdoc index b31687a..aab46f6 100644 --- a/doc/shell.mdoc +++ b/doc/shell.mdoc @@ -169,6 +169,7 @@ file copied from .Pa $HOME/skel . .Bd -literal -offset Ds $ shell -s "$HOME/skel" ksh -l +Copying /home/myself/skel into /tmp/shell-ksh.4DzEG6qr Starting /bin/ksh in /tmp/shell-ksh.4DzEG6qr $ ls -la total 16 diff --git a/src/shell.in b/src/shell.in index 723d4ba..4269e71 100644 --- a/src/shell.in +++ b/src/shell.in @@ -46,7 +46,7 @@ _get_solaris_shells () END_LIST } -get_shells () +_get_shells () { # Returns a list of absolute paths to installed shells. The shells # are validated (it's made sure that they are executable files) @@ -85,7 +85,7 @@ get_shells () done } -force=0 # when 1, bypasses the call to get_shells +force=0 # when 1, bypasses the call to _get_shells keep=0 # when 1, does not remove working directory when exiting while getopts 'd:fks:v' opt; do case "$opt" in @@ -123,13 +123,13 @@ fi if [ "$force" -eq 0 ]; then # Get the absolute path to a real shell. If multiple shells are - # returned from get_shells, we will use the first one. - realshell="$( get_shells | sed -n '\#/'"${shell##*/}"'$#{p;q;}' )" + # returned from _get_shells, we will use the first one. + realshell="$( _get_shells | sed -n '\#/'"${shell##*/}"'$#{p;q;}' )" if [ -z "$realshell" ]; then _error 'No such shell: %s\n' "$shell" echo 'Valid shells:' >&2 - get_shells | awk '{ printf("\t%s\n", $0) }' >&2 + _get_shells | awk '{ printf("\t%s\n", $0) }' >&2 exit 1 fi elif [ ! -x "$shell" ]; then @@ -166,10 +166,11 @@ if [ -n "$skel" ]; then exit 1 fi + printf 'Copying %s into %s\n' "$skel" "$tmpwd" >&2 if command -v pax >/dev/null 2>&1; then ( cd -- "$skel" && pax -rw -p p . "$tmpwd" ) elif command -v tar >/dev/null 2>&1; then - tar -cv -f - -C "$skel" . | tar -x -p -f - -C "$tmpwd" + tar -c -f - -C "$skel" . | tar -x -p -f - -C "$tmpwd" else _error 'Can not use pax nor tar to copy "%s" to "%s"\n' "$skel" "$tmpwd" exit 1 From 56301c3ee8e88e7df9173294f274d7e54b8c8061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Thu, 19 Apr 2018 07:53:27 +0200 Subject: [PATCH 30/54] Plans --- TODO | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index 2c9470b..3bd0ad4 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,4 @@ For "shell": -* Nothing at the moment. + * Add USR1 signal handler that stops the temporary directory from + being deleted when the script is exiting. From f717ee3f223f4586b9409ffab32786aeda0a96f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Thu, 19 Apr 2018 07:53:44 +0200 Subject: [PATCH 31/54] regen --- doc/shell.man | 1 + doc/shell.md | 1 + doc/shell.txt | 1 + 3 files changed, 3 insertions(+) diff --git a/doc/shell.man b/doc/shell.man index 7813c61..6fdedc2 100644 --- a/doc/shell.man +++ b/doc/shell.man @@ -192,6 +192,7 @@ file copied from .sp .RS 6n $ shell -s "$HOME/skel" ksh -l +Copying /home/myself/skel into /tmp/shell-ksh.4DzEG6qr Starting /bin/ksh in /tmp/shell-ksh.4DzEG6qr $ ls -la total 16 diff --git a/doc/shell.md b/doc/shell.md index c22658d..c13d92d 100644 --- a/doc/shell.md +++ b/doc/shell.md @@ -192,6 +192,7 @@ file copied from *$HOME/skel*. $ shell -s "$HOME/skel" ksh -l + Copying /home/myself/skel into /tmp/shell-ksh.4DzEG6qr Starting /bin/ksh in /tmp/shell-ksh.4DzEG6qr $ ls -la total 16 diff --git a/doc/shell.txt b/doc/shell.txt index 10b23e5..e9590fd 100644 --- a/doc/shell.txt +++ b/doc/shell.txt @@ -111,6 +111,7 @@ EXAMPLES $HOME/skel. $ shell -s "$HOME/skel" ksh -l + Copying /home/myself/skel into /tmp/shell-ksh.4DzEG6qr Starting /bin/ksh in /tmp/shell-ksh.4DzEG6qr $ ls -la total 16 From 4e19cb402a907414d10ff1e352fae3ae90ada5a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Thu, 19 Apr 2018 08:25:36 +0200 Subject: [PATCH 32/54] Move EXIT trap code into _exit_handler function --- src/shell.in | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/shell.in b/src/shell.in index 4269e71..c3ea9f5 100644 --- a/src/shell.in +++ b/src/shell.in @@ -85,6 +85,15 @@ _get_shells () done } +_exit_handler () { + if [ "$keep" -eq 1 ]; then + printf "Leaving %s in place\n" "$tmpwd" >&2 + else + printf "Removing %s\n" "$tmpwd" >&2 + cd / && rm -rf -- "$tmpwd" + fi +} + force=0 # when 1, bypasses the call to _get_shells keep=0 # when 1, does not remove working directory when exiting while getopts 'd:fks:v' opt; do @@ -154,11 +163,7 @@ elif [ ! -d "$tmpwd" ]; then fi fi -if [ "$keep" -eq 1 ]; then - trap 'printf "Leaving %s in place\n" "$tmpwd" >&2' EXIT -else - trap 'printf "Removing %s\n" "$tmpwd" >&2; cd / && rm -rf "$tmpwd"' EXIT -fi +trap _exit_handler EXIT if [ -n "$skel" ]; then if [ ! -d "$skel" ]; then From b2bb84226622918ec860e0bb9ccf8b31c8827566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Thu, 19 Apr 2018 08:27:38 +0200 Subject: [PATCH 33/54] Add _usr1_handler that simply sets keep=1 upon SIGUSR1 --- src/shell.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/shell.in b/src/shell.in index c3ea9f5..400bf8f 100644 --- a/src/shell.in +++ b/src/shell.in @@ -94,6 +94,8 @@ _exit_handler () { fi } +_usr1_handler () { keep=1; } + force=0 # when 1, bypasses the call to _get_shells keep=0 # when 1, does not remove working directory when exiting while getopts 'd:fks:v' opt; do @@ -164,6 +166,7 @@ elif [ ! -d "$tmpwd" ]; then fi trap _exit_handler EXIT +trap _usr1_handler USR1 if [ -n "$skel" ]; then if [ ! -d "$skel" ]; then From 9e8bcfd8a6b78a4b762a72bbf5d3e9a1475db7e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Thu, 19 Apr 2018 09:39:44 +0200 Subject: [PATCH 34/54] Add USR1 signal handler feature to NEWS --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index 7579fb7..07cd3f7 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,9 @@ Next release * Added NEWS file. * Added -v option to output version information. + * Added USR1 signal handler that will stop the temporary directory + from being deleted when the shell exits (as if -k had been used from + the start). * Let the configure script figure out whether "mktemp -t" adds ".XXXXXXXX" to the end of the given template or not. * Don't choke on directories whose name start with a dash. From b70a4ac09da80027999534431a5252affc47a5ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Thu, 19 Apr 2018 09:40:17 +0200 Subject: [PATCH 35/54] Done --- TODO | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/TODO b/TODO index 3bd0ad4..b530244 100644 --- a/TODO +++ b/TODO @@ -1,4 +1 @@ -For "shell": - - * Add USR1 signal handler that stops the temporary directory from - being deleted when the script is exiting. + * shell: Nothing at the moment. From e176e6ad5ef42ebc1fdfbcd7ba691014c14660fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Thu, 19 Apr 2018 09:40:38 +0200 Subject: [PATCH 36/54] Document USR1 signal behaviour --- doc/shell.mdoc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/shell.mdoc b/doc/shell.mdoc index aab46f6..5321331 100644 --- a/doc/shell.mdoc +++ b/doc/shell.mdoc @@ -48,6 +48,16 @@ Any operands present after the name of the .Ar shell will be passed as is to the shell in question. .Pp +If +.Nm +(this utility, +.Em not +the interactive shell process) receives the USR1 signal, the temporary +working directory will not be deleted when the shell session terminates +(as if +.Fl k +had been used from the start). +.Pp The options are as follows: .Bl -tag -width Ds .It Fl d Ar directory From fa97ae57345a622ff995a3179bb7a9f397bf9da9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Thu, 19 Apr 2018 09:41:08 +0200 Subject: [PATCH 37/54] regen --- doc/shell.man | 12 +++++++++++- doc/shell.md | 12 +++++++++++- doc/shell.txt | 6 +++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/doc/shell.man b/doc/shell.man index 6fdedc2..738d279 100644 --- a/doc/shell.man +++ b/doc/shell.man @@ -1,4 +1,4 @@ -.TH "SHELL" "1" "April 18, 2018" "Unix" "General Commands Manual" +.TH "SHELL" "1" "April 19, 2018" "Unix" "General Commands Manual" .nh .if n .ad l .SH "NAME" @@ -55,6 +55,16 @@ Any operands present after the name of the \fIshell\fR will be passed as is to the shell in question. .PP +If +\fBshell\fR +(this utility, +\fInot\fR +the interactive shell process) receives the USR1 signal, the temporary +working directory will not be deleted when the shell session terminates +(as if +\fB\-k\fR +had been used from the start). +.PP The options are as follows: .TP 8n \fB\-d\fR \fIdirectory\fR diff --git a/doc/shell.md b/doc/shell.md index c13d92d..e8c7c8c 100644 --- a/doc/shell.md +++ b/doc/shell.md @@ -51,6 +51,16 @@ Any operands present after the name of the *shell* will be passed as is to the shell in question. +If +**shell** +(this utility, +*not* +the interactive shell process) receives the USR1 signal, the temporary +working directory will not be deleted when the shell session terminates +(as if +**-k** +had been used from the start). + The options are as follows: **-d** *directory* @@ -229,4 +239,4 @@ The */etc/shells* file will still be used if it exists. -Unix - April 18, 2018 +Unix - April 19, 2018 diff --git a/doc/shell.txt b/doc/shell.txt index e9590fd..0a1a24c 100644 --- a/doc/shell.txt +++ b/doc/shell.txt @@ -27,6 +27,10 @@ DESCRIPTION Any operands present after the name of the shell will be passed as is to the shell in question. + If shell (this utility, not the interactive shell process) receives the + USR1 signal, the temporary working directory will not be deleted when the + shell session terminates (as if -k had been used from the start). + The options are as follows: -d directory @@ -138,4 +142,4 @@ CAVEATS "getent shells" and may also lack the /etc/shells file. The /etc/shells file will still be used if it exists. -Unix April 18, 2018 Unix +Unix April 19, 2018 Unix From 93ac362d07e16e79f020adf49faf6ef5ab0fc207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Thu, 19 Apr 2018 10:42:32 +0200 Subject: [PATCH 38/54] Fix issues reported by shellcheck --- src/shell.in | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/shell.in b/src/shell.in index 400bf8f..2f57282 100644 --- a/src/shell.in +++ b/src/shell.in @@ -18,6 +18,9 @@ _error () # stderr: error message printf 'shell: ' >&2 + + # We mimic printf here, disable shellcheck test. + # shellcheck disable=SC2059 printf "$@" >&2 } @@ -78,7 +81,7 @@ _get_shells () exit 1 fi fi | - while read realshell; do + while read -r realshell; do if [ -x "$realshell" ]; then printf '%s\n' "$realshell" fi @@ -87,9 +90,9 @@ _get_shells () _exit_handler () { if [ "$keep" -eq 1 ]; then - printf "Leaving %s in place\n" "$tmpwd" >&2 + printf 'Leaving %s in place\n' "$tmpwd" >&2 else - printf "Removing %s\n" "$tmpwd" >&2 + printf 'Removing %s\n' "$tmpwd" >&2 cd / && rm -rf -- "$tmpwd" fi } From a30a1ac727adec299531ce55a8fdb79f2477931f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Thu, 19 Apr 2018 15:48:10 +0200 Subject: [PATCH 39/54] Added thing --- TODO | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/TODO b/TODO index b530244..5ec7406 100644 --- a/TODO +++ b/TODO @@ -1 +1,5 @@ + * Possibly factor out utility functions into separate "library". + This will not happen until the toolbox contains more than a single + script. + * shell: Nothing at the moment. From 85120dc1f0726298527c092121120992588ec916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Thu, 19 Apr 2018 15:49:47 +0200 Subject: [PATCH 40/54] Various * Clean up function names. I initially used a "_" prefix on some function names, but this is not needed (executive decision). * Change _error() into errorf() and take answer to U&L question into account. See https://unix.stackexchange.com/questions/438694 * Smaller changes to error messages. * Prepare for a future when there may be more than one tool in the toolbox by setting UTIL to "shell" and using that in errorf() and the new output_version() function. The UTIL variable may change name later. --- src/shell.in | 68 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/src/shell.in b/src/shell.in index 2f57282..343ef67 100644 --- a/src/shell.in +++ b/src/shell.in @@ -3,11 +3,13 @@ # Part of @PACKAGE_STRING@ # For bug reports, see "@PACKAGE_BUGREPORT@" +UTIL=shell + # Variables set by the configure script: MKTEMP="@MKTEMP@" MKTEMP_TEMPLATE="@MKTEMP_TEMPLATE@" -_error () +errorf () { # Simple function for outputting error messages. Prefixes the error # message with the name of the utility. @@ -17,14 +19,27 @@ _error () # stdout: unused # stderr: error message - printf 'shell: ' >&2 + # We mimic printf here, disable shellcheck warnings. + # See https://unix.stackexchange.com/questions/438694 + # shellcheck disable=SC2059,SC2145 + printf "$UTIL: ERROR: $@" >&2 +} + +output_version () +{ + # Simple function for outputting version information. + + # Parameters: none + # stdin: unused + # stdout: unused + # stderr: version information - # We mimic printf here, disable shellcheck test. - # shellcheck disable=SC2059 - printf "$@" >&2 + printf '%s: part of %s (release "%s")\n' \ + "$UTIL" "@PACKAGE_NAME@" "@PACKAGE_VERSION@" + printf 'For bug reports, see %s\n' "@PACKAGE_BUGREPORT@" } -_get_solaris_shells () +get_solaris_shells () { # Returns a list of valid Solaris 11.4 shells. The list is taken # from the shells(4) manual and is shortened to only contain one @@ -49,7 +64,7 @@ _get_solaris_shells () END_LIST } -_get_shells () +get_shells () { # Returns a list of absolute paths to installed shells. The shells # are validated (it's made sure that they are executable files) @@ -73,11 +88,10 @@ _get_shells () ! grep '^[^#]' /etc/shells 2>/dev/null then if [ "$( uname -s )" = "SunOS" ]; then - _get_solaris_shells + get_solaris_shells else - _error 'Can not get list of shells!\n' - _error 'Please file a bug report at\n' - _error '@PACKAGE_BUGREPORT@\n' + errorf 'Can not get list of shells!\n' + errorf 'Please file a bug report at\n%s\n' "@PACKAGE_BUGREPORT@" exit 1 fi fi | @@ -99,7 +113,7 @@ _exit_handler () { _usr1_handler () { keep=1; } -force=0 # when 1, bypasses the call to _get_shells +force=0 # when 1, bypasses the call to get_shells keep=0 # when 1, does not remove working directory when exiting while getopts 'd:fks:v' opt; do case "$opt" in @@ -108,18 +122,16 @@ while getopts 'd:fks:v' opt; do f) force=1 ;; k) keep=1 ;; s) skel=$OPTARG ;; - v) printf 'shell: part of %s (release "%s")\n' \ - "@PACKAGE_NAME@" "@PACKAGE_VERSION@" - printf 'For bug reports, see %s\n' "@PACKAGE_BUGREPORT@" - exit 0 ;; - *) _error 'error while parsing the command line\n' + v) output_version + exit 0 ;; + *) errorf 'Unknown option on command line\n' exit 1 esac done shift "$(( OPTIND - 1 ))" if [ -n "$tmpwd" ] && [ -n "$skel" ]; then - _error 'Can not use both the -d and the -s option at the same time\n' + errorf 'Can not use both the -d and the -s option at the same time\n' exit 1 fi @@ -131,23 +143,23 @@ else fi if [ -z "$shell" ]; then - _error 'Can not determine what shell to start\n' + errorf 'Can not determine what shell to start\n' exit 1 fi if [ "$force" -eq 0 ]; then # Get the absolute path to a real shell. If multiple shells are - # returned from _get_shells, we will use the first one. - realshell="$( _get_shells | sed -n '\#/'"${shell##*/}"'$#{p;q;}' )" + # returned from get_shells, we will use the first one. + realshell="$( get_shells | sed -n '\#/'"${shell##*/}"'$#{p;q;}' )" if [ -z "$realshell" ]; then - _error 'No such shell: %s\n' "$shell" + errorf 'No such shell: %s\n' "$shell" echo 'Valid shells:' >&2 - _get_shells | awk '{ printf("\t%s\n", $0) }' >&2 + get_shells | awk '{ printf("\t%s\n", $0) }' >&2 exit 1 fi elif [ ! -x "$shell" ]; then - _error 'No such executable: %s\n' "$shell" + errorf 'No such executable: %s\n' "$shell" exit 1 else realshell="$shell" @@ -158,12 +170,12 @@ if [ -z "$tmpwd" ]; then tmpwd="$( "$MKTEMP" -d -t "$template" )" elif [ ! -d "$tmpwd" ]; then if [ -e "$tmpwd" ]; then - _error '"%s" exists, but is not a directory\n' "$tmpwd" + errorf '"%s" exists, but is not a directory\n' "$tmpwd" exit 1 fi if ! mkdir -p "$tmpwd"; then - _error 'Failed to create directory "%s"\n' "$tmpwd" + errorf 'Failed to create directory "%s"\n' "$tmpwd" exit 1 fi fi @@ -173,7 +185,7 @@ trap _usr1_handler USR1 if [ -n "$skel" ]; then if [ ! -d "$skel" ]; then - _error 'The -s option was used, but "%s" does not exist\n' "$skel" + errorf 'Can not find skeleton directory "%s"\n' "$skel" exit 1 fi @@ -183,7 +195,7 @@ if [ -n "$skel" ]; then elif command -v tar >/dev/null 2>&1; then tar -c -f - -C "$skel" . | tar -x -p -f - -C "$tmpwd" else - _error 'Can not use pax nor tar to copy "%s" to "%s"\n' "$skel" "$tmpwd" + errorf 'Can not use pax nor tar to copy "%s" to "%s"\n' "$skel" "$tmpwd" exit 1 fi fi From 05930c60f07433eab9f621f4434f1058db9bff5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Thu, 19 Apr 2018 22:29:07 +0200 Subject: [PATCH 41/54] Added friendly text --- INSTALL | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/INSTALL b/INSTALL index 3013d99..770951d 100644 --- a/INSTALL +++ b/INSTALL @@ -25,7 +25,26 @@ To install using GNU Stow under "$HOME/local": Then make sure that "$HOME/local/bin" is in your "$PATH". +The following files will be installed unless the default installation +paths are modified: + + / + |-- bin + | `-- shell + `-- share + |-- doc + | `-- shell-toolbox + | |-- LICENSE + | |-- NEWS + | |-- README + | |-- shell.md + | `-- shell.txt + `-- man + `-- man1 + `-- shell.1 + Caveat: If you run "make distclean", the generated manuals, which are part of the distribution sources, will be removed. These won't be rebuilt unless you have mandoc(1) installed. + From eb3eda7bb0562fe879ca8e1ae4c86e2c89a29967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Thu, 19 Apr 2018 22:30:12 +0200 Subject: [PATCH 42/54] Various * Renamed signal handlers. * Add test for skeleton directory before creating temprorary directory. Avoids creating and then immediately deleting the directroy when we find out that the skeleton directory does'nt exist. * Make the error messages more uniform. --- src/shell.in | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/shell.in b/src/shell.in index 343ef67..db2013d 100644 --- a/src/shell.in +++ b/src/shell.in @@ -102,7 +102,7 @@ get_shells () done } -_exit_handler () { +exit_handler () { if [ "$keep" -eq 1 ]; then printf 'Leaving %s in place\n' "$tmpwd" >&2 else @@ -111,7 +111,7 @@ _exit_handler () { fi } -_usr1_handler () { keep=1; } +usr1_handler () { keep=1; } force=0 # when 1, bypasses the call to get_shells keep=0 # when 1, does not remove working directory when exiting @@ -165,30 +165,30 @@ else realshell="$shell" fi +if [ -n "$skel" ] && [ ! -d "$skel" ]; then + errorf 'No such directory: %s\n' "$skel" + exit 1 +fi + if [ -z "$tmpwd" ]; then template="shell-${shell##*/}$MKTEMP_TEMPLATE" tmpwd="$( "$MKTEMP" -d -t "$template" )" elif [ ! -d "$tmpwd" ]; then if [ -e "$tmpwd" ]; then - errorf '"%s" exists, but is not a directory\n' "$tmpwd" + errorf 'No such directory: %s\n' "$tmpwd" exit 1 fi if ! mkdir -p "$tmpwd"; then - errorf 'Failed to create directory "%s"\n' "$tmpwd" + errorf 'Failed to create directory: %s\n' "$tmpwd" exit 1 fi fi -trap _exit_handler EXIT -trap _usr1_handler USR1 +trap exit_handler EXIT +trap usr1_handler USR1 if [ -n "$skel" ]; then - if [ ! -d "$skel" ]; then - errorf 'Can not find skeleton directory "%s"\n' "$skel" - exit 1 - fi - printf 'Copying %s into %s\n' "$skel" "$tmpwd" >&2 if command -v pax >/dev/null 2>&1; then ( cd -- "$skel" && pax -rw -p p . "$tmpwd" ) From 382621e16ad5a558928bdc8700b3df58e22dfe36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Fri, 20 Apr 2018 20:14:24 +0200 Subject: [PATCH 43/54] Added note about systems with no make(1) --- INSTALL | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/INSTALL b/INSTALL index 770951d..e438167 100644 --- a/INSTALL +++ b/INSTALL @@ -28,7 +28,7 @@ Then make sure that "$HOME/local/bin" is in your "$PATH". The following files will be installed unless the default installation paths are modified: - / + |-- bin | `-- shell `-- share @@ -48,3 +48,13 @@ Caveat: If you run "make distclean", the generated manuals, which are part of the distribution sources, will be removed. These won't be rebuilt unless you have mandoc(1) installed. +Using the tools without access to "make": + +After running the configure script, the generated Makefiles are actually +just (currently) used for installing the various files in the correct +locations. If you are on a system where "make" is not available (due to +arbitrary decisions/omissions by the system administrators), then you +may just copy the generated scripts from the "src" folder (and possibly +the manuals from "doc") to wherever you want to keep them. + +Note that the tools have not been thoroughly tested to work this way. From 89c6bbd3d7c65d85b554afd695e6f0bc35762a8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Sat, 21 Apr 2018 10:11:47 +0200 Subject: [PATCH 44/54] Clarification --- INSTALL | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/INSTALL b/INSTALL index e438167..096eb25 100644 --- a/INSTALL +++ b/INSTALL @@ -53,8 +53,9 @@ Using the tools without access to "make": After running the configure script, the generated Makefiles are actually just (currently) used for installing the various files in the correct locations. If you are on a system where "make" is not available (due to -arbitrary decisions/omissions by the system administrators), then you -may just copy the generated scripts from the "src" folder (and possibly -the manuals from "doc") to wherever you want to keep them. +arbitrary decisions/omissions by the system administrators), assuming +you have run the configure script, then you may just copy the generated +scripts from the "src" folder (and possibly the manuals from "doc") to +wherever you want to keep them. Note that the tools have not been thoroughly tested to work this way. From f06551067b1431889449081cfd3870c143b41f64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Sat, 21 Apr 2018 14:42:05 +0200 Subject: [PATCH 45/54] Don't mind release checklist --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a86c3f1..3befbcd 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,6 @@ Makefile autom4te.cache config.log config.status +release-checklist.txt shell-toolbox-*.tar.gz src/shell From fc70e0ce75904d22de3c393802f20b144897deaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Sat, 21 Apr 2018 14:44:13 +0200 Subject: [PATCH 46/54] Various * Rename some utility functions, again. * Add pinfof() for outputting informational messages. * HUP script if we can't get list of shells. * Add -q option to make script quiet. --- src/shell.in | 63 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/src/shell.in b/src/shell.in index db2013d..3723c27 100644 --- a/src/shell.in +++ b/src/shell.in @@ -3,13 +3,14 @@ # Part of @PACKAGE_STRING@ # For bug reports, see "@PACKAGE_BUGREPORT@" -UTIL=shell +utility_name=shell # used in perrorf() and pinfo() +main_pid=$$ # used in get_shells() # Variables set by the configure script: MKTEMP="@MKTEMP@" MKTEMP_TEMPLATE="@MKTEMP_TEMPLATE@" -errorf () +perrorf () { # Simple function for outputting error messages. Prefixes the error # message with the name of the utility. @@ -22,7 +23,18 @@ errorf () # We mimic printf here, disable shellcheck warnings. # See https://unix.stackexchange.com/questions/438694 # shellcheck disable=SC2059,SC2145 - printf "$UTIL: ERROR: $@" >&2 + printf "$utility_name: ERROR: $@" >&2 +} + +pinfof () +{ + # Same as above, but with 'INFO:' instead of 'ERROR:'. Also + # disables output if the global variable $quiet is 1. + + if [ "${quiet:-0}" -ne 1 ]; then + # shellcheck disable=SC2059,SC2145 + printf "$utility_name: INFO: $@" >&2 + fi } output_version () @@ -34,9 +46,8 @@ output_version () # stdout: unused # stderr: version information - printf '%s: part of %s (release "%s")\n' \ - "$UTIL" "@PACKAGE_NAME@" "@PACKAGE_VERSION@" - printf 'For bug reports, see %s\n' "@PACKAGE_BUGREPORT@" + pinfof 'Part of %s (release "%s")\n' "@PACKAGE_NAME@" "@PACKAGE_VERSION@" + pinfof 'For bug reports, see %s\n' "@PACKAGE_BUGREPORT@" } get_solaris_shells () @@ -90,9 +101,12 @@ get_shells () if [ "$( uname -s )" = "SunOS" ]; then get_solaris_shells else - errorf 'Can not get list of shells!\n' - errorf 'Please file a bug report at\n%s\n' "@PACKAGE_BUGREPORT@" - exit 1 + perrorf 'Can not get list of shells!\n' + perrorf 'Please file a bug report at %s\n' "@PACKAGE_BUGREPORT@" + # We HUP the script here since if we "exit 1" instead, we + # will be left it the main part of the script and get further + # error messages before properly terminating. + kill -s HUP "$main_pid" fi fi | while read -r realshell; do @@ -104,9 +118,9 @@ get_shells () exit_handler () { if [ "$keep" -eq 1 ]; then - printf 'Leaving %s in place\n' "$tmpwd" >&2 + pinfof 'Leaving %s in place\n' "$tmpwd" >&2 else - printf 'Removing %s\n' "$tmpwd" >&2 + pinfof 'Removing %s\n' "$tmpwd" >&2 cd / && rm -rf -- "$tmpwd" fi } @@ -115,23 +129,25 @@ usr1_handler () { keep=1; } force=0 # when 1, bypasses the call to get_shells keep=0 # when 1, does not remove working directory when exiting -while getopts 'd:fks:v' opt; do +quiet=0 # when 1, informational messages are not outputted +while getopts 'd:fks:qv' opt; do case "$opt" in d) tmpwd=$OPTARG keep=1 ;; f) force=1 ;; k) keep=1 ;; + q) quiet=1 ;; s) skel=$OPTARG ;; v) output_version exit 0 ;; - *) errorf 'Unknown option on command line\n' + *) perrorf 'Unknown option on command line\n' exit 1 esac done shift "$(( OPTIND - 1 ))" if [ -n "$tmpwd" ] && [ -n "$skel" ]; then - errorf 'Can not use both the -d and the -s option at the same time\n' + perrorf 'Can not use both the -d and the -s option at the same time\n' exit 1 fi @@ -143,7 +159,7 @@ else fi if [ -z "$shell" ]; then - errorf 'Can not determine what shell to start\n' + perrorf 'Can not determine what shell to start\n' exit 1 fi @@ -153,20 +169,20 @@ if [ "$force" -eq 0 ]; then realshell="$( get_shells | sed -n '\#/'"${shell##*/}"'$#{p;q;}' )" if [ -z "$realshell" ]; then - errorf 'No such shell: %s\n' "$shell" + perrorf 'No such shell: %s\n' "$shell" echo 'Valid shells:' >&2 get_shells | awk '{ printf("\t%s\n", $0) }' >&2 exit 1 fi elif [ ! -x "$shell" ]; then - errorf 'No such executable: %s\n' "$shell" + perrorf 'No such executable: %s\n' "$shell" exit 1 else realshell="$shell" fi if [ -n "$skel" ] && [ ! -d "$skel" ]; then - errorf 'No such directory: %s\n' "$skel" + perrorf 'No such directory: %s\n' "$skel" exit 1 fi @@ -175,12 +191,12 @@ if [ -z "$tmpwd" ]; then tmpwd="$( "$MKTEMP" -d -t "$template" )" elif [ ! -d "$tmpwd" ]; then if [ -e "$tmpwd" ]; then - errorf 'No such directory: %s\n' "$tmpwd" + perrorf 'No such directory: %s\n' "$tmpwd" exit 1 fi if ! mkdir -p "$tmpwd"; then - errorf 'Failed to create directory: %s\n' "$tmpwd" + perrorf 'Failed to create directory: %s\n' "$tmpwd" exit 1 fi fi @@ -189,18 +205,19 @@ trap exit_handler EXIT trap usr1_handler USR1 if [ -n "$skel" ]; then - printf 'Copying %s into %s\n' "$skel" "$tmpwd" >&2 + pinfof 'Copying %s into %s\n' "$skel" "$tmpwd" >&2 if command -v pax >/dev/null 2>&1; then ( cd -- "$skel" && pax -rw -p p . "$tmpwd" ) elif command -v tar >/dev/null 2>&1; then tar -c -f - -C "$skel" . | tar -x -p -f - -C "$tmpwd" else - errorf 'Can not use pax nor tar to copy "%s" to "%s"\n' "$skel" "$tmpwd" + perrorf 'Can not use pax nor tar to copy "%s" to "%s"\n' \ + "$skel" "$tmpwd" exit 1 fi fi -printf 'Starting %s in %s\n' "$realshell" "$tmpwd" >&2 +pinfof 'Starting %s in %s\n' "$realshell" "$tmpwd" >&2 cd -- "$tmpwd" && env -i HOME="$tmpwd" \ From 5ba3b3502d520b41493c7ffdc4105cf7d3119ba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Sat, 21 Apr 2018 14:46:30 +0200 Subject: [PATCH 47/54] Various * Document new -q option. * Minor rewordings. * Refresh examples. --- doc/shell.mdoc | 53 ++++++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/doc/shell.mdoc b/doc/shell.mdoc index 5321331..caf064e 100644 --- a/doc/shell.mdoc +++ b/doc/shell.mdoc @@ -7,10 +7,12 @@ .Sh SYNOPSIS .Nm shell .Op Fl f +.Op Fl q .Op Fl d Ar directory | Fl k .Op Ar shell Op Ar ... .Nm .Op Fl f +.Op Fl q .Op Fl s Ar directory .Op Fl k .Op Ar shell Op Ar ... @@ -74,6 +76,9 @@ Force the execution of the given command, even if it is not a valid login shell on the current system. .It Fl k Keep the temporary directory around after terminating the shell session. +.It Fl q +Be quiet. +Don't output informational messages. .It Fl s Ar directory Pre-populate the temporary directory with the contents of the named directory. @@ -123,8 +128,8 @@ environment. Set to the absolute path of the real shell executable. This may be different from the .Ar shell -mentioned on the command line as the actual shell used will always be -picked from the list of valid login shells (unless +mentioned on the command line as the actual shell used will be picked +from the list of valid login shells (unless .Fl f is used). .It Ev TERM @@ -141,19 +146,19 @@ does not work. Start a new shell in a new temporary directory: .Bd -literal -offset Ds $ shell -Starting /bin/ksh in /tmp/shell-ksh.lDv4uX48 +shell: INFO: Starting /bin/ksh in /tmp/shell-ksh.mJMHFTFE $ exit -Removing /tmp/shell-ksh.lDv4uX48 +shell: INFO: Removing /tmp/shell-ksh.mJMHFTFE .Ed .Pp Start a new -.Cm ksh93 +.Cm dash shell in a temporary directory: .Bd -literal -offset Ds -$ shell ksh93 -Starting /usr/local/bin/ksh93 in /tmp/shell-ksh93.oct61lxx -myself:/tmp/shell-ksh93.oct61lxx:1$ exit -Removing /tmp/shell-ksh93.oct61lxx +$ shell dash +shell: INFO: Starting /usr/local/bin/dash in /tmp/shell-dash.V7zU6EtZ +$ exit +shell: INFO: Removing /tmp/shell-dash.V7zU6EtZ .Ed .Pp Start a new @@ -161,9 +166,10 @@ Start a new shell in a specific directory: .Bd -literal -offset Ds $ shell -d "$HOME/testing" bash -Starting /usr/local/bin/bash in /home/myself/testing +shell: INFO: Starting /usr/local/bin/bash in /home/myself/testing $ exit -Leaving /home/myself/testing in place +exit +shell: INFO: Leaving /home/myself/testing in place .Ed .Pp Start @@ -179,20 +185,21 @@ file copied from .Pa $HOME/skel . .Bd -literal -offset Ds $ shell -s "$HOME/skel" ksh -l -Copying /home/myself/skel into /tmp/shell-ksh.4DzEG6qr -Starting /bin/ksh in /tmp/shell-ksh.4DzEG6qr +shell: INFO: Copying /home/myself/skel into /tmp/shell-ksh.ngEwbcpD +shell: INFO: Starting /bin/ksh in /tmp/shell-ksh.ngEwbcpD $ ls -la -total 16 -drwx------ 3 myself wheel 512 Feb 9 10:18 . -drwxrwxrwt 4 root wheel 512 Apr 8 18:49 .. --rw-r--r-- 1 myself wheel 87 Nov 1 19:14 .Xdefaults --rw-r--r-- 1 myself wheel 771 Feb 9 10:18 .cshrc --rw-r--r-- 1 myself wheel 101 Nov 1 19:14 .cvsrc --rw-r--r-- 1 myself wheel 359 Nov 1 19:14 .login --rw-r--r-- 1 myself wheel 175 Nov 1 19:14 .mailrc --rw-r--r-- 1 myself wheel 215 Feb 9 10:18 .profile +total 36 +drwxr-xr-x 2 myself wheel 512 Apr 15 12:55 . +drwxrwxrwt 28 root wheel 512 Apr 21 14:15 .. +-rw-r--r-- 1 myself wheel 87 Nov 1 19:14 .Xdefaults +-rw-r--r-- 1 myself wheel 771 Feb 9 10:18 .cshrc +-rw-r--r-- 1 myself wheel 101 Nov 1 19:14 .cvsrc +-rw-r--r-- 1 myself wheel 359 Nov 1 19:14 .login +-rw-r--r-- 1 myself wheel 175 Nov 1 19:14 .mailrc +-rw-r--r-- 1 myself wheel 215 Feb 9 10:18 .profile +-rw-r--r-- 1 myself wheel 108 Apr 15 12:50 .vimrc $ exit -Removing /tmp/shell-ksh.4DzEG6qr +shell: INFO: Removing /tmp/shell-ksh.ngEwbcpD .Ed .Sh SEE ALSO .Xr mktemp 1 From 02436ff8656f52a1945969d4ca3cc26ae7fea293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Sat, 21 Apr 2018 14:47:30 +0200 Subject: [PATCH 48/54] Mention new -q option --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index 07cd3f7..bef6baa 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,6 @@ Next release * Added NEWS file. + * Added -q option for quiet operation. * Added -v option to output version information. * Added USR1 signal handler that will stop the temporary directory from being deleted when the shell exits (as if -k had been used from From 506ce2ae98a3ade07ea798e5e7e51d985baa62c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Sat, 21 Apr 2018 14:50:11 +0200 Subject: [PATCH 49/54] Minor, comments --- configure.ac | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index da469b1..fc09ff4 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,6 @@ AC_PREREQ([2.69]) -AC_INIT([shell-toolbox],[post-20180415],[https://github.com/kusalananda/shell-toolbox/issues]) +AC_INIT([shell-toolbox],[post-20180415], + [https://github.com/kusalananda/shell-toolbox/issues]) AC_CONFIG_AUX_DIR([build]) @@ -11,6 +12,9 @@ AC_CONFIG_SRCDIR([src/shell.in]) # Test whether mktemp exists, and if it does, whether "mktemp -t" adds # .XXXXXXXX to the filename template or not. This is better than # testing with "uname" in the src/shell.in script. +# Note: The *minimum* number of X's on OpenBSD is six, while the +# *maximum* number of X's on Solaris is six (Solaris "mktemp -t" will +# only use the last six of the eight X's we give it here). AC_PATH_PROG(MKTEMP, [mktemp]) AS_IF([test -n "$MKTEMP"], [AC_MSG_CHECKING([whether $MKTEMP -t adds .XXXXXXXX to template]) From 4e0bf06176b3f64e457a24c3f52943be665ac6be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Sat, 21 Apr 2018 14:50:39 +0200 Subject: [PATCH 50/54] regen --- configure | 3 +++ doc/shell.man | 56 ++++++++++++++++++++++++++++---------------------- doc/shell.md | 57 +++++++++++++++++++++++++++++---------------------- doc/shell.txt | 56 +++++++++++++++++++++++++++----------------------- 4 files changed, 98 insertions(+), 74 deletions(-) diff --git a/configure b/configure index da4751a..a7aa8ef 100755 --- a/configure +++ b/configure @@ -2394,6 +2394,9 @@ fi # Test whether mktemp exists, and if it does, whether "mktemp -t" adds # .XXXXXXXX to the filename template or not. This is better than # testing with "uname" in the src/shell.in script. +# Note: The *minimum* number of X's on OpenBSD is six, while the +# *maximum* number of X's on Solaris is six (Solaris "mktemp -t" will +# only use the last six of the eight X's we give it here). # Extract the first word of "mktemp", so it can be a program name with args. set dummy mktemp; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 diff --git a/doc/shell.man b/doc/shell.man index 738d279..dbc22df 100644 --- a/doc/shell.man +++ b/doc/shell.man @@ -1,4 +1,4 @@ -.TH "SHELL" "1" "April 19, 2018" "Unix" "General Commands Manual" +.TH "SHELL" "1" "April 21, 2018" "Unix" "General Commands Manual" .nh .if n .ad l .SH "NAME" @@ -8,6 +8,7 @@ .HP 6n \fBshell\fR [\fB\-f\fR] +[\fB\-q\fR] [\fB\-d\fR\ \fIdirectory\fR\ |\ \fB\-k\fR] [\fIshell\fR\ [\fI...\fR]] .br @@ -15,6 +16,7 @@ .HP 6n \fBshell\fR [\fB\-f\fR] +[\fB\-q\fR] [\fB\-s\fR\ \fIdirectory\fR] [\fB\-k\fR] [\fIshell\fR\ [\fI...\fR]] @@ -84,6 +86,10 @@ login shell on the current system. \fB\-k\fR Keep the temporary directory around after terminating the shell session. .TP 8n +\fB\-q\fR +Be quiet. +Don't output informational messages. +.TP 8n \fB\-s\fR \fIdirectory\fR Pre-populate the temporary directory with the contents of the named directory. @@ -136,8 +142,8 @@ environment. Set to the absolute path of the real shell executable. This may be different from the \fIshell\fR -mentioned on the command line as the actual shell used will always be -picked from the list of valid login shells (unless +mentioned on the command line as the actual shell used will be picked +from the list of valid login shells (unless \fB\-f\fR is used). .TP 8n @@ -155,22 +161,22 @@ Start a new shell in a new temporary directory: .sp .RS 6n $ shell -Starting /bin/ksh in /tmp/shell-ksh.lDv4uX48 +shell: INFO: Starting /bin/ksh in /tmp/shell-ksh.mJMHFTFE $ exit -Removing /tmp/shell-ksh.lDv4uX48 +shell: INFO: Removing /tmp/shell-ksh.mJMHFTFE .RE .fi .PP Start a new -\fBksh93\fR +\fBdash\fR shell in a temporary directory: .nf .sp .RS 6n -$ shell ksh93 -Starting /usr/local/bin/ksh93 in /tmp/shell-ksh93.oct61lxx -myself:/tmp/shell-ksh93.oct61lxx:1$ exit -Removing /tmp/shell-ksh93.oct61lxx +$ shell dash +shell: INFO: Starting /usr/local/bin/dash in /tmp/shell-dash.V7zU6EtZ +$ exit +shell: INFO: Removing /tmp/shell-dash.V7zU6EtZ .RE .fi .PP @@ -181,9 +187,10 @@ shell in a specific directory: .sp .RS 6n $ shell -d "$HOME/testing" bash -Starting /usr/local/bin/bash in /home/myself/testing +shell: INFO: Starting /usr/local/bin/bash in /home/myself/testing $ exit -Leaving /home/myself/testing in place +exit +shell: INFO: Leaving /home/myself/testing in place .RE .fi .PP @@ -202,20 +209,21 @@ file copied from .sp .RS 6n $ shell -s "$HOME/skel" ksh -l -Copying /home/myself/skel into /tmp/shell-ksh.4DzEG6qr -Starting /bin/ksh in /tmp/shell-ksh.4DzEG6qr +shell: INFO: Copying /home/myself/skel into /tmp/shell-ksh.ngEwbcpD +shell: INFO: Starting /bin/ksh in /tmp/shell-ksh.ngEwbcpD $ ls -la -total 16 -drwx------ 3 myself wheel 512 Feb 9 10:18 . -drwxrwxrwt 4 root wheel 512 Apr 8 18:49 .. --rw-r--r-- 1 myself wheel 87 Nov 1 19:14 .Xdefaults --rw-r--r-- 1 myself wheel 771 Feb 9 10:18 .cshrc --rw-r--r-- 1 myself wheel 101 Nov 1 19:14 .cvsrc --rw-r--r-- 1 myself wheel 359 Nov 1 19:14 .login --rw-r--r-- 1 myself wheel 175 Nov 1 19:14 .mailrc --rw-r--r-- 1 myself wheel 215 Feb 9 10:18 .profile +total 36 +drwxr-xr-x 2 myself wheel 512 Apr 15 12:55 . +drwxrwxrwt 28 root wheel 512 Apr 21 14:15 .. +-rw-r--r-- 1 myself wheel 87 Nov 1 19:14 .Xdefaults +-rw-r--r-- 1 myself wheel 771 Feb 9 10:18 .cshrc +-rw-r--r-- 1 myself wheel 101 Nov 1 19:14 .cvsrc +-rw-r--r-- 1 myself wheel 359 Nov 1 19:14 .login +-rw-r--r-- 1 myself wheel 175 Nov 1 19:14 .mailrc +-rw-r--r-- 1 myself wheel 215 Feb 9 10:18 .profile +-rw-r--r-- 1 myself wheel 108 Apr 15 12:50 .vimrc $ exit -Removing /tmp/shell-ksh.4DzEG6qr +shell: INFO: Removing /tmp/shell-ksh.ngEwbcpD .RE .fi .SH "SEE ALSO" diff --git a/doc/shell.md b/doc/shell.md index e8c7c8c..60bc584 100644 --- a/doc/shell.md +++ b/doc/shell.md @@ -8,10 +8,12 @@ SHELL(1) - General Commands Manual **shell** \[**-f**] +\[**-q**] \[**-d** *directory* | **-k**] \[*shell* \[*...*]] **shell** \[**-f**] +\[**-q**] \[**-s** *directory*] \[**-k**] \[*shell* \[*...*]] @@ -83,6 +85,11 @@ The options are as follows: > Keep the temporary directory around after terminating the shell session. +**-q** + +> Be quiet. +> Don't output informational messages. + **-s** *directory* > Pre-populate the temporary directory with the contents of the named @@ -145,8 +152,8 @@ also sets the following environment variables: > Set to the absolute path of the real shell executable. > This may be different from the > *shell* -> mentioned on the command line as the actual shell used will always be -> picked from the list of valid login shells (unless +> mentioned on the command line as the actual shell used will be picked +> from the list of valid login shells (unless > **-f** > is used). @@ -167,27 +174,28 @@ also sets the following environment variables: Start a new shell in a new temporary directory: $ shell - Starting /bin/ksh in /tmp/shell-ksh.lDv4uX48 + shell: INFO: Starting /bin/ksh in /tmp/shell-ksh.mJMHFTFE $ exit - Removing /tmp/shell-ksh.lDv4uX48 + shell: INFO: Removing /tmp/shell-ksh.mJMHFTFE Start a new -**ksh93** +**dash** shell in a temporary directory: - $ shell ksh93 - Starting /usr/local/bin/ksh93 in /tmp/shell-ksh93.oct61lxx - myself:/tmp/shell-ksh93.oct61lxx:1$ exit - Removing /tmp/shell-ksh93.oct61lxx + $ shell dash + shell: INFO: Starting /usr/local/bin/dash in /tmp/shell-dash.V7zU6EtZ + $ exit + shell: INFO: Removing /tmp/shell-dash.V7zU6EtZ Start a new **bash** shell in a specific directory: $ shell -d "$HOME/testing" bash - Starting /usr/local/bin/bash in /home/myself/testing + shell: INFO: Starting /usr/local/bin/bash in /home/myself/testing $ exit - Leaving /home/myself/testing in place + exit + shell: INFO: Leaving /home/myself/testing in place Start **ksh** @@ -202,20 +210,21 @@ file copied from *$HOME/skel*. $ shell -s "$HOME/skel" ksh -l - Copying /home/myself/skel into /tmp/shell-ksh.4DzEG6qr - Starting /bin/ksh in /tmp/shell-ksh.4DzEG6qr + shell: INFO: Copying /home/myself/skel into /tmp/shell-ksh.ngEwbcpD + shell: INFO: Starting /bin/ksh in /tmp/shell-ksh.ngEwbcpD $ ls -la - total 16 - drwx------ 3 myself wheel 512 Feb 9 10:18 . - drwxrwxrwt 4 root wheel 512 Apr 8 18:49 .. - -rw-r--r-- 1 myself wheel 87 Nov 1 19:14 .Xdefaults - -rw-r--r-- 1 myself wheel 771 Feb 9 10:18 .cshrc - -rw-r--r-- 1 myself wheel 101 Nov 1 19:14 .cvsrc - -rw-r--r-- 1 myself wheel 359 Nov 1 19:14 .login - -rw-r--r-- 1 myself wheel 175 Nov 1 19:14 .mailrc - -rw-r--r-- 1 myself wheel 215 Feb 9 10:18 .profile + total 36 + drwxr-xr-x 2 myself wheel 512 Apr 15 12:55 . + drwxrwxrwt 28 root wheel 512 Apr 21 14:15 .. + -rw-r--r-- 1 myself wheel 87 Nov 1 19:14 .Xdefaults + -rw-r--r-- 1 myself wheel 771 Feb 9 10:18 .cshrc + -rw-r--r-- 1 myself wheel 101 Nov 1 19:14 .cvsrc + -rw-r--r-- 1 myself wheel 359 Nov 1 19:14 .login + -rw-r--r-- 1 myself wheel 175 Nov 1 19:14 .mailrc + -rw-r--r-- 1 myself wheel 215 Feb 9 10:18 .profile + -rw-r--r-- 1 myself wheel 108 Apr 15 12:50 .vimrc $ exit - Removing /tmp/shell-ksh.4DzEG6qr + shell: INFO: Removing /tmp/shell-ksh.ngEwbcpD # SEE ALSO @@ -239,4 +248,4 @@ The */etc/shells* file will still be used if it exists. -Unix - April 19, 2018 +Unix - April 21, 2018 diff --git a/doc/shell.txt b/doc/shell.txt index 0a1a24c..9804149 100644 --- a/doc/shell.txt +++ b/doc/shell.txt @@ -5,8 +5,8 @@ NAME working directory SYNOPSIS - shell [-f] [-d directory | -k] [shell [...]] - shell [-f] [-s directory] [-k] [shell [...]] + shell [-f] [-q] [-d directory | -k] [shell [...]] + shell [-f] [-q] [-s directory] [-k] [shell [...]] shell -v DESCRIPTION @@ -46,6 +46,8 @@ DESCRIPTION -k Keep the temporary directory around after terminating the shell session. + -q Be quiet. Don't output informational messages. + -s directory Pre-populate the temporary directory with the contents of the named directory. This will copy the whole directory structure @@ -77,8 +79,8 @@ ENVIRONMENT SHELL Set to the absolute path of the real shell executable. This may be different from the shell mentioned on the command line as the - actual shell used will always be picked from the list of valid - login shells (unless -f is used). + actual shell used will be picked from the list of valid login + shells (unless -f is used). TERM Carried over from the parent environment. @@ -91,23 +93,24 @@ EXAMPLES Start a new shell in a new temporary directory: $ shell - Starting /bin/ksh in /tmp/shell-ksh.lDv4uX48 + shell: INFO: Starting /bin/ksh in /tmp/shell-ksh.mJMHFTFE $ exit - Removing /tmp/shell-ksh.lDv4uX48 + shell: INFO: Removing /tmp/shell-ksh.mJMHFTFE - Start a new ksh93 shell in a temporary directory: + Start a new dash shell in a temporary directory: - $ shell ksh93 - Starting /usr/local/bin/ksh93 in /tmp/shell-ksh93.oct61lxx - myself:/tmp/shell-ksh93.oct61lxx:1$ exit - Removing /tmp/shell-ksh93.oct61lxx + $ shell dash + shell: INFO: Starting /usr/local/bin/dash in /tmp/shell-dash.V7zU6EtZ + $ exit + shell: INFO: Removing /tmp/shell-dash.V7zU6EtZ Start a new bash shell in a specific directory: $ shell -d "$HOME/testing" bash - Starting /usr/local/bin/bash in /home/myself/testing + shell: INFO: Starting /usr/local/bin/bash in /home/myself/testing $ exit - Leaving /home/myself/testing in place + exit + shell: INFO: Leaving /home/myself/testing in place Start ksh as a login shell and pre-populate the temporary directory with the contents of $HOME/skel. Note, starting the ksh shell as a login @@ -115,20 +118,21 @@ EXAMPLES $HOME/skel. $ shell -s "$HOME/skel" ksh -l - Copying /home/myself/skel into /tmp/shell-ksh.4DzEG6qr - Starting /bin/ksh in /tmp/shell-ksh.4DzEG6qr + shell: INFO: Copying /home/myself/skel into /tmp/shell-ksh.ngEwbcpD + shell: INFO: Starting /bin/ksh in /tmp/shell-ksh.ngEwbcpD $ ls -la - total 16 - drwx------ 3 myself wheel 512 Feb 9 10:18 . - drwxrwxrwt 4 root wheel 512 Apr 8 18:49 .. - -rw-r--r-- 1 myself wheel 87 Nov 1 19:14 .Xdefaults - -rw-r--r-- 1 myself wheel 771 Feb 9 10:18 .cshrc - -rw-r--r-- 1 myself wheel 101 Nov 1 19:14 .cvsrc - -rw-r--r-- 1 myself wheel 359 Nov 1 19:14 .login - -rw-r--r-- 1 myself wheel 175 Nov 1 19:14 .mailrc - -rw-r--r-- 1 myself wheel 215 Feb 9 10:18 .profile + total 36 + drwxr-xr-x 2 myself wheel 512 Apr 15 12:55 . + drwxrwxrwt 28 root wheel 512 Apr 21 14:15 .. + -rw-r--r-- 1 myself wheel 87 Nov 1 19:14 .Xdefaults + -rw-r--r-- 1 myself wheel 771 Feb 9 10:18 .cshrc + -rw-r--r-- 1 myself wheel 101 Nov 1 19:14 .cvsrc + -rw-r--r-- 1 myself wheel 359 Nov 1 19:14 .login + -rw-r--r-- 1 myself wheel 175 Nov 1 19:14 .mailrc + -rw-r--r-- 1 myself wheel 215 Feb 9 10:18 .profile + -rw-r--r-- 1 myself wheel 108 Apr 15 12:50 .vimrc $ exit - Removing /tmp/shell-ksh.4DzEG6qr + shell: INFO: Removing /tmp/shell-ksh.ngEwbcpD SEE ALSO mktemp(1) @@ -142,4 +146,4 @@ CAVEATS "getent shells" and may also lack the /etc/shells file. The /etc/shells file will still be used if it exists. -Unix April 19, 2018 Unix +Unix April 21, 2018 Unix From 1eecde49842d0dca8593185076e37f14fb7de06c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Sat, 21 Apr 2018 18:14:42 +0200 Subject: [PATCH 51/54] Remove --- INSTALL | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/INSTALL b/INSTALL index 096eb25..f283113 100644 --- a/INSTALL +++ b/INSTALL @@ -43,19 +43,7 @@ paths are modified: `-- man1 `-- shell.1 - Caveat: If you run "make distclean", the generated manuals, which are part of the distribution sources, will be removed. These won't be rebuilt unless you have mandoc(1) installed. -Using the tools without access to "make": - -After running the configure script, the generated Makefiles are actually -just (currently) used for installing the various files in the correct -locations. If you are on a system where "make" is not available (due to -arbitrary decisions/omissions by the system administrators), assuming -you have run the configure script, then you may just copy the generated -scripts from the "src" folder (and possibly the manuals from "doc") to -wherever you want to keep them. - -Note that the tools have not been thoroughly tested to work this way. From 3a0b3e925ef419c945efefc5b2d1c94ee77a8de9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Sun, 22 Apr 2018 12:26:07 +0200 Subject: [PATCH 52/54] Update release numbers --- NEWS | 2 +- configure.ac | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index bef6baa..74cd3dd 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -Next release +Release 20180422 * Added NEWS file. * Added -q option for quiet operation. * Added -v option to output version information. diff --git a/configure.ac b/configure.ac index fc09ff4..77dd0bb 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.69]) -AC_INIT([shell-toolbox],[post-20180415], +AC_INIT([shell-toolbox],[20180422], [https://github.com/kusalananda/shell-toolbox/issues]) AC_CONFIG_AUX_DIR([build]) From 459548f3a2f84c120641a2081dbd8fd2d2c0f6a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Sun, 22 Apr 2018 12:26:36 +0200 Subject: [PATCH 53/54] regen --- configure | 20 ++++++++++---------- doc/shell.man | 3 ++- doc/shell.md | 2 +- doc/shell.txt | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/configure b/configure index a7aa8ef..1582a76 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69.195-487d6 for shell-toolbox post-20180415. +# Generated by GNU Autoconf 2.69.195-487d6 for shell-toolbox 20180422. # # Report bugs to . # @@ -565,8 +565,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='shell-toolbox' PACKAGE_TARNAME='shell-toolbox' -PACKAGE_VERSION='post-20180415' -PACKAGE_STRING='shell-toolbox post-20180415' +PACKAGE_VERSION='20180422' +PACKAGE_STRING='shell-toolbox 20180422' PACKAGE_BUGREPORT='https://github.com/kusalananda/shell-toolbox/issues' PACKAGE_URL='' @@ -1206,7 +1206,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures shell-toolbox post-20180415 to adapt to many kinds of systems. +\`configure' configures shell-toolbox 20180422 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1273,7 +1273,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of shell-toolbox post-20180415:";; + short | recursive ) echo "Configuration of shell-toolbox 20180422:";; esac cat <<\_ACEOF @@ -1350,7 +1350,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -shell-toolbox configure post-20180415 +shell-toolbox configure 20180422 generated by GNU Autoconf 2.69.195-487d6 Copyright (C) 2017 Free Software Foundation, Inc. @@ -1387,7 +1387,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by shell-toolbox $as_me post-20180415, which was +It was created by shell-toolbox $as_me 20180422, which was generated by GNU Autoconf 2.69.195-487d6. Invocation command line was $ $0$ac_configure_args_raw @@ -2275,7 +2275,7 @@ fi # Define the identity of the package. PACKAGE='shell-toolbox' - VERSION='post-20180415' + VERSION='20180422' printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h @@ -3107,7 +3107,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by shell-toolbox $as_me post-20180415, which was +This file was extended by shell-toolbox $as_me 20180422, which was generated by GNU Autoconf 2.69.195-487d6. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -3162,7 +3162,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ -shell-toolbox config.status post-20180415 +shell-toolbox config.status 20180422 configured by $0, generated by GNU Autoconf 2.69.195-487d6, with options \\"\$ac_cs_config\\" diff --git a/doc/shell.man b/doc/shell.man index dbc22df..11763f9 100644 --- a/doc/shell.man +++ b/doc/shell.man @@ -1,4 +1,5 @@ -.TH "SHELL" "1" "April 21, 2018" "Unix" "General Commands Manual" +.\" Automatically generated from an mdoc input file. Do not edit. +.TH "SHELL" "1" "April 22, 2018" "Unix" "General Commands Manual" .nh .if n .ad l .SH "NAME" diff --git a/doc/shell.md b/doc/shell.md index 60bc584..eb8920c 100644 --- a/doc/shell.md +++ b/doc/shell.md @@ -248,4 +248,4 @@ The */etc/shells* file will still be used if it exists. -Unix - April 21, 2018 +Unix - April 22, 2018 diff --git a/doc/shell.txt b/doc/shell.txt index 9804149..2d7bc88 100644 --- a/doc/shell.txt +++ b/doc/shell.txt @@ -146,4 +146,4 @@ CAVEATS "getent shells" and may also lack the /etc/shells file. The /etc/shells file will still be used if it exists. -Unix April 21, 2018 Unix +Unix April 22, 2018 Unix From 3d21a07efcbb7e4ffb4906479c5b7ed4595f7426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=28Kusalananda=29=20K=C3=A4h=C3=A4ri?= Date: Sun, 22 Apr 2018 12:27:06 +0200 Subject: [PATCH 54/54] cosmetics --- INSTALL | 1 - 1 file changed, 1 deletion(-) diff --git a/INSTALL b/INSTALL index f283113..ceb83c7 100644 --- a/INSTALL +++ b/INSTALL @@ -46,4 +46,3 @@ paths are modified: Caveat: If you run "make distclean", the generated manuals, which are part of the distribution sources, will be removed. These won't be rebuilt unless you have mandoc(1) installed. -