diff --git a/.gitignore b/.gitignore index 3befbcd..3489b97 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ Makefile autom4te.cache config.log config.status +local.env release-checklist.txt shell-toolbox-*.tar.gz src/shell diff --git a/INSTALL b/INSTALL index ceb83c7..923275b 100644 --- a/INSTALL +++ b/INSTALL @@ -1,48 +1,60 @@ -This project uses GNU autotools. - -To install the scripts under "/usr/local" (scripts will always go in the -"bin" subdirectory): - - ./configure - make - make install - -Then make sure that "/usr/local/bin" is in your "$PATH". - -To install under "$HOME/local": - - ./configure --prefix="$HOME/local" - make - make install - -To install using GNU Stow under "$HOME/local": - - ./configure --prefix="$HOME/local/stow/shell-toolbox" - make - make install - cd "$HOME/local/stow" - stow shell-toolbox - -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. +1. Installing from the distribution tar archive or a GitHub clone: + + This project uses GNU autotools. + + To install the scripts under "/usr/local" (scripts will always go in + the "bin" subdirectory): + + ./configure + make + make install + + Then make sure that "/usr/local/bin" is in your "$PATH". + + To install under "$HOME/local": + + ./configure --prefix="$HOME/local" + make + make install + + To install using GNU Stow under "$HOME/local": + + ./configure --prefix="$HOME/local/stow/shell-toolbox" + make + make install + cd "$HOME/local/stow" + stow shell-toolbox + + 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. + +2. Installing on FreeBSD: + + The devel/shell-toolbox port: + + cd /usr/ports/devel/shell-toolbox/ && make install clean + + The shell-toolbox package: + + pkg install shell-toolbox diff --git a/Makefile.in b/Makefile.in index f3a0481..587090a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -252,7 +252,6 @@ 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/NEWS b/NEWS index 74cd3dd..49fe04e 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,11 @@ +Release 20180719 + * A skeleton directory (to pre-populate the temporary working + directory with) may be specified by setting the SHELL_SKEL + environment variable to the path of a directory. This environment + variable is not used if the command line option -s or -d is used. + * /bin/sh is used if SHELL is empty or unset and no other shell is + specified. + Release 20180422 * Added NEWS file. * Added -q option for quiet operation. diff --git a/TODO b/TODO index 5ec7406..44640fd 100644 --- a/TODO +++ b/TODO @@ -2,4 +2,6 @@ This will not happen until the toolbox contains more than a single script. + * Write the shell code formatter script/program. + * shell: Nothing at the moment. diff --git a/aclocal.m4 b/aclocal.m4 index c0f7c1a..60d8fe6 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -108,6 +108,43 @@ AC_DEFUN([AM_AUX_DIR_EXPAND], am_aux_dir=`cd "$ac_aux_dir" && pwd` ]) +# AM_COND_IF -*- Autoconf -*- + +# Copyright (C) 2008-2018 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# _AM_COND_IF +# _AM_COND_ELSE +# _AM_COND_ENDIF +# -------------- +# These macros are only used for tracing. +m4_define([_AM_COND_IF]) +m4_define([_AM_COND_ELSE]) +m4_define([_AM_COND_ENDIF]) + +# AM_COND_IF(COND, [IF-TRUE], [IF-FALSE]) +# --------------------------------------- +# If the shell condition COND is true, execute IF-TRUE, otherwise execute +# IF-FALSE. Allow automake to learn about conditional instantiating macros +# (the AC_CONFIG_FOOS). +AC_DEFUN([AM_COND_IF], +[m4_ifndef([_AM_COND_VALUE_$1], + [m4_fatal([$0: no such condition "$1"])])dnl +_AM_COND_IF([$1])dnl +if test -z "$$1_TRUE"; then : + m4_n([$2])[]dnl +m4_ifval([$3], +[_AM_COND_ELSE([$1])dnl +else + $3 +])dnl +_AM_COND_ENDIF([$1])dnl +fi[]dnl +]) + # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997-2018 Free Software Foundation, Inc. diff --git a/configure b/configure index 1582a76..007ca1f 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 20180422. +# Generated by GNU Autoconf 2.69.195-487d6 for shell-toolbox 20180719. # # Report bugs to . # @@ -565,17 +565,18 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='shell-toolbox' PACKAGE_TARNAME='shell-toolbox' -PACKAGE_VERSION='20180422' -PACKAGE_STRING='shell-toolbox 20180422' +PACKAGE_VERSION='20180719' +PACKAGE_STRING='shell-toolbox 20180719' PACKAGE_BUGREPORT='https://github.com/kusalananda/shell-toolbox/issues' PACKAGE_URL='' ac_unique_file="src/shell.in" ac_subst_vars='LTLIBOBJS LIBOBJS -MANDOC_DOES_MARKDOWN -MANDOC +BUILD_MANUALS_FALSE +BUILD_MANUALS_TRUE COL +MANDOC MKTEMP_TEMPLATE MKTEMP MAINT @@ -1206,7 +1207,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 20180422 to adapt to many kinds of systems. +\`configure' configures shell-toolbox 20180719 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1273,7 +1274,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of shell-toolbox 20180422:";; + short | recursive ) echo "Configuration of shell-toolbox 20180719:";; esac cat <<\_ACEOF @@ -1350,7 +1351,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -shell-toolbox configure 20180422 +shell-toolbox configure 20180719 generated by GNU Autoconf 2.69.195-487d6 Copyright (C) 2017 Free Software Foundation, Inc. @@ -1387,7 +1388,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 20180422, which was +It was created by shell-toolbox $as_me 20180719, which was generated by GNU Autoconf 2.69.195-487d6. Invocation command line was $ $0$ac_configure_args_raw @@ -2275,7 +2276,7 @@ fi # Define the identity of the package. PACKAGE='shell-toolbox' - VERSION='20180422' + VERSION='20180719' printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h @@ -2468,17 +2469,17 @@ fi # 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 +# 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 @@ -2492,7 +2493,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 @@ -2503,27 +2504,27 @@ 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 -# Extract the first word of "mandoc", so it can be a program name with args. -set dummy mandoc; ac_word=$2 +# 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 @@ -2537,7 +2538,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 @@ -2548,32 +2549,49 @@ 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 -if test -n "$MANDOC" -then : + if test -n "$MANDOC" && test -n "$COL"; then + BUILD_MANUALS_TRUE= + BUILD_MANUALS_FALSE='#' +else + BUILD_MANUALS_TRUE='#' + BUILD_MANUALS_FALSE= +fi + + +if test -z "$BUILD_MANUALS_TRUE"; 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 : - MANDOC_DOES_MARKDOWN=yes + if "$MANDOC" -T markdown /dev/null; then + BUILD_MANUALS_TRUE= + BUILD_MANUALS_FALSE='#' else - MANDOC_DOES_MARKDOWN=no + BUILD_MANUALS_TRUE='#' + BUILD_MANUALS_FALSE= fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MANDOC_DOES_MARKDOWN" >&5 -printf "%s\n" "$MANDOC_DOES_MARKDOWN" >&6; } + if test -z "$BUILD_MANUALS_TRUE"; then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } 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;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi +fi + +if test -z "$BUILD_MANUALS_TRUE"; then : + else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: col or usable mandoc is missing, manuals can not be rebuilt" >&5 +printf "%s\n" "$as_me: WARNING: col or usable mandoc is missing, manuals can not be rebuilt" >&2;} fi ac_config_files="$ac_config_files Makefile src/Makefile doc/Makefile" @@ -2738,6 +2756,14 @@ if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${BUILD_MANUALS_TRUE}" && test -z "${BUILD_MANUALS_FALSE}"; then + as_fn_error $? "conditional \"BUILD_MANUALS\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${BUILD_MANUALS_TRUE}" && test -z "${BUILD_MANUALS_FALSE}"; then + as_fn_error $? "conditional \"BUILD_MANUALS\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 @@ -3107,7 +3133,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 20180422, which was +This file was extended by shell-toolbox $as_me 20180719, which was generated by GNU Autoconf 2.69.195-487d6. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -3162,7 +3188,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 20180422 +shell-toolbox config.status 20180719 configured by $0, generated by GNU Autoconf 2.69.195-487d6, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 77dd0bb..38b4fa7 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,5 @@ AC_PREREQ([2.69]) -AC_INIT([shell-toolbox],[20180422], - [https://github.com/kusalananda/shell-toolbox/issues]) +AC_INIT([shell-toolbox],[20180719],[https://github.com/kusalananda/shell-toolbox/issues]) AC_CONFIG_AUX_DIR([build]) @@ -33,16 +32,20 @@ AS_IF([test -n "$MKTEMP"], # 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"], +AC_PATH_PROG(COL, [col]) +AM_CONDITIONAL([BUILD_MANUALS], [test -n "$MANDOC" && test -n "$COL"]) + +AM_COND_IF([BUILD_MANUALS], [AC_MSG_CHECKING([whether $MANDOC can produce markdown output]) - AS_IF(["$MANDOC" -T markdown /dev/null], - [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]) ]) + AM_CONDITIONAL([BUILD_MANUALS], + ["$MANDOC" -T markdown /dev/null]) + AM_COND_IF([BUILD_MANUALS], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no])]) ]) + +AM_COND_IF([BUILD_MANUALS], [], + [AC_MSG_WARN([col or usable 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]) diff --git a/doc/Makefile.am b/doc/Makefile.am index 11a5a2f..7b151b4 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -3,17 +3,22 @@ dist_doc_DATA= shell.md shell.txt EXTRA_DIST= shell.mdoc DISTCLEANFILES= shell.man shell.md shell.txt +if !BUILD_MANUALS + +$(dist_man1_MANS) $(dist_doc_DATA): + @echo 'You lack the mandoc utility. Can not rebuild manuals' >&2 + @exit 1 + +else + shell.man: $(srcdir)/shell.mdoc - test -n "$(MANDOC)" && \ $(MANDOC) -T man -I os=Unix $(srcdir)/shell.mdoc >shell.man || true shell.md: $(srcdir)/shell.mdoc - test -n "$(MANDOC)" && \ - test "$(MANDOC_DOES_MARKDOWN)" = "yes" && \ $(MANDOC) -T markdown -I os=Unix $(srcdir)/shell.mdoc >shell.md || true shell.txt: $(srcdir)/shell.mdoc - test -n "$(MANDOC)" && \ - test -n "$(COL)" && \ $(MANDOC) -T ascii -I os=Unix $(srcdir)/shell.mdoc | \ $(COL) -b >shell.txt || true + +endif # BUILD_MANUALS diff --git a/doc/Makefile.in b/doc/Makefile.in index 7ceabb6..3b4138c 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -174,7 +174,6 @@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANDOC = @MANDOC@ -MANDOC_DOES_MARKDOWN = @MANDOC_DOES_MARKDOWN@ MKDIR_P = @MKDIR_P@ MKTEMP = @MKTEMP@ MKTEMP_TEMPLATE = @MKTEMP_TEMPLATE@ @@ -492,20 +491,19 @@ uninstall-man: uninstall-man1 .PRECIOUS: Makefile -shell.man: $(srcdir)/shell.mdoc - test -n "$(MANDOC)" && \ - $(MANDOC) -T man -I os=Unix $(srcdir)/shell.mdoc >shell.man || true +@BUILD_MANUALS_FALSE@$(dist_man1_MANS) $(dist_doc_DATA): +@BUILD_MANUALS_FALSE@ @echo 'You lack the mandoc utility. Can not rebuild manuals' >&2 +@BUILD_MANUALS_FALSE@ @exit 1 -shell.md: $(srcdir)/shell.mdoc - test -n "$(MANDOC)" && \ - test "$(MANDOC_DOES_MARKDOWN)" = "yes" && \ - $(MANDOC) -T markdown -I os=Unix $(srcdir)/shell.mdoc >shell.md || true +@BUILD_MANUALS_TRUE@shell.man: $(srcdir)/shell.mdoc +@BUILD_MANUALS_TRUE@ $(MANDOC) -T man -I os=Unix $(srcdir)/shell.mdoc >shell.man || true -shell.txt: $(srcdir)/shell.mdoc - test -n "$(MANDOC)" && \ - test -n "$(COL)" && \ - $(MANDOC) -T ascii -I os=Unix $(srcdir)/shell.mdoc | \ - $(COL) -b >shell.txt || true +@BUILD_MANUALS_TRUE@shell.md: $(srcdir)/shell.mdoc +@BUILD_MANUALS_TRUE@ $(MANDOC) -T markdown -I os=Unix $(srcdir)/shell.mdoc >shell.md || true + +@BUILD_MANUALS_TRUE@shell.txt: $(srcdir)/shell.mdoc +@BUILD_MANUALS_TRUE@ $(MANDOC) -T ascii -I os=Unix $(srcdir)/shell.mdoc | \ +@BUILD_MANUALS_TRUE@ $(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/doc/shell.man b/doc/shell.man index 11763f9..f649762 100644 --- a/doc/shell.man +++ b/doc/shell.man @@ -1,5 +1,5 @@ .\" Automatically generated from an mdoc input file. Do not edit. -.TH "SHELL" "1" "April 22, 2018" "Unix" "General Commands Manual" +.TH "SHELL" "1" "July 19, 2018" "Unix" "General Commands Manual" .nh .if n .ad l .SH "NAME" @@ -83,6 +83,7 @@ option. \fB\-f\fR Force the execution of the given command, even if it is not a valid login shell on the current system. +The command needs to be specified with an absolute path. .TP 8n \fB\-k\fR Keep the temporary directory around after terminating the shell session. @@ -106,6 +107,22 @@ Output version information and immediately terminate. \fBshell\fR uses the following environment variables: .TP 8n +\fRSHELL\fR +Used to determine what shell to start if a specific +\fIshell\fR +is not specified on the command line. +If this variable is unset or empty, then +\fB/bin/sh\fR +will be used instead. +.TP 8n +\fRSHELL_SKEL\fR +Directory to automatically pre-populate the temporary working directory with. +This environment variable is not used if any of the +\fB\-d\fR +or +\fB\-s\fR +options are used on the command line. +.TP 8n \fRTMPDIR\fR Directory in which to create the working directory when the \fB\-d\fR @@ -115,11 +132,6 @@ This variable is used by which will revert to use \fI/tmp\fR if the variable is not set. -.TP 8n -\fRSHELL\fR -Used to determine what shell to start if a specific -\fIshell\fR -is not specified on the command line. .PP \fBshell\fR clears the environment of the interactive shell that it starts, but @@ -162,9 +174,9 @@ Start a new shell in a new temporary directory: .sp .RS 6n $ shell -shell: INFO: Starting /bin/ksh in /tmp/shell-ksh.mJMHFTFE +shell: info: Starting /bin/ksh in /tmp/shell-ksh.mJMHFTFE $ exit -shell: INFO: Removing /tmp/shell-ksh.mJMHFTFE +shell: info: Removing /tmp/shell-ksh.mJMHFTFE .RE .fi .PP @@ -175,9 +187,9 @@ shell in a temporary directory: .sp .RS 6n $ shell dash -shell: INFO: Starting /usr/local/bin/dash in /tmp/shell-dash.V7zU6EtZ +shell: info: Starting /usr/local/bin/dash in /tmp/shell-dash.V7zU6EtZ $ exit -shell: INFO: Removing /tmp/shell-dash.V7zU6EtZ +shell: info: Removing /tmp/shell-dash.V7zU6EtZ .RE .fi .PP @@ -188,10 +200,10 @@ shell in a specific directory: .sp .RS 6n $ shell -d "$HOME/testing" bash -shell: INFO: Starting /usr/local/bin/bash in /home/myself/testing +shell: info: Starting /usr/local/bin/bash in /home/myself/testing $ exit exit -shell: INFO: Leaving /home/myself/testing in place +shell: info: Leaving /home/myself/testing in place .RE .fi .PP @@ -210,8 +222,8 @@ file copied from .sp .RS 6n $ shell -s "$HOME/skel" ksh -l -shell: INFO: Copying /home/myself/skel into /tmp/shell-ksh.ngEwbcpD -shell: INFO: Starting /bin/ksh in /tmp/shell-ksh.ngEwbcpD +shell: info: Copying /home/myself/skel into /tmp/shell-ksh.ngEwbcpD +shell: info: Starting /bin/ksh in /tmp/shell-ksh.ngEwbcpD $ ls -la total 36 drwxr-xr-x 2 myself wheel 512 Apr 15 12:55 . @@ -224,7 +236,7 @@ drwxrwxrwt 28 root wheel 512 Apr 21 14:15 .. -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 -shell: INFO: Removing /tmp/shell-ksh.ngEwbcpD +shell: info: Removing /tmp/shell-ksh.ngEwbcpD .RE .fi .SH "SEE ALSO" diff --git a/doc/shell.md b/doc/shell.md index eb8920c..1bef967 100644 --- a/doc/shell.md +++ b/doc/shell.md @@ -80,6 +80,7 @@ The options are as follows: > Force the execution of the given command, even if it is not a valid > login shell on the current system. +> The command needs to be specified with an absolute path. **-k** @@ -109,6 +110,24 @@ The options are as follows: **shell** uses the following environment variables: +`SHELL` + +> Used to determine what shell to start if a specific +> *shell* +> is not specified on the command line. +> If this variable is unset or empty, then +> **/bin/sh** +> will be used instead. + +`SHELL_SKEL` + +> Directory to automatically pre-populate the temporary working directory with. +> This environment variable is not used if any of the +> **-d** +> or +> **-s** +> options are used on the command line. + `TMPDIR` > Directory in which to create the working directory when the @@ -120,12 +139,6 @@ uses the following environment variables: > */tmp* > if the variable is not set. -`SHELL` - -> Used to determine what shell to start if a specific -> *shell* -> is not specified on the command line. - **shell** clears the environment of the interactive shell that it starts, but also sets the following environment variables: @@ -174,28 +187,28 @@ also sets the following environment variables: Start a new shell in a new temporary directory: $ shell - shell: INFO: Starting /bin/ksh in /tmp/shell-ksh.mJMHFTFE + shell: info: Starting /bin/ksh in /tmp/shell-ksh.mJMHFTFE $ exit - shell: INFO: Removing /tmp/shell-ksh.mJMHFTFE + shell: info: Removing /tmp/shell-ksh.mJMHFTFE Start a new **dash** shell in a temporary directory: $ shell dash - shell: INFO: Starting /usr/local/bin/dash in /tmp/shell-dash.V7zU6EtZ + shell: info: Starting /usr/local/bin/dash in /tmp/shell-dash.V7zU6EtZ $ exit - shell: INFO: Removing /tmp/shell-dash.V7zU6EtZ + shell: info: Removing /tmp/shell-dash.V7zU6EtZ Start a new **bash** shell in a specific directory: $ shell -d "$HOME/testing" bash - shell: INFO: Starting /usr/local/bin/bash in /home/myself/testing + shell: info: Starting /usr/local/bin/bash in /home/myself/testing $ exit exit - shell: INFO: Leaving /home/myself/testing in place + shell: info: Leaving /home/myself/testing in place Start **ksh** @@ -210,8 +223,8 @@ file copied from *$HOME/skel*. $ shell -s "$HOME/skel" ksh -l - shell: INFO: Copying /home/myself/skel into /tmp/shell-ksh.ngEwbcpD - shell: INFO: Starting /bin/ksh in /tmp/shell-ksh.ngEwbcpD + shell: info: Copying /home/myself/skel into /tmp/shell-ksh.ngEwbcpD + shell: info: Starting /bin/ksh in /tmp/shell-ksh.ngEwbcpD $ ls -la total 36 drwxr-xr-x 2 myself wheel 512 Apr 15 12:55 . @@ -224,7 +237,7 @@ file copied from -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 - shell: INFO: Removing /tmp/shell-ksh.ngEwbcpD + shell: info: Removing /tmp/shell-ksh.ngEwbcpD # SEE ALSO @@ -248,4 +261,4 @@ The */etc/shells* file will still be used if it exists. -Unix - April 22, 2018 +Unix - July 19, 2018 diff --git a/doc/shell.mdoc b/doc/shell.mdoc index caf064e..a3b466c 100644 --- a/doc/shell.mdoc +++ b/doc/shell.mdoc @@ -74,6 +74,7 @@ option. .It Fl f Force the execution of the given command, even if it is not a valid login shell on the current system. +The command needs to be specified with an absolute path. .It Fl k Keep the temporary directory around after terminating the shell session. .It Fl q @@ -94,6 +95,20 @@ Output version information and immediately terminate. .Nm uses the following environment variables: .Bl -tag -width Ds +.It Ev SHELL +Used to determine what shell to start if a specific +.Ar shell +is not specified on the command line. +If this variable is unset or empty, then +.Cm /bin/sh +will be used instead. +.It Ev SHELL_SKEL +Directory to automatically pre-populate the temporary working directory with. +This environment variable is not used if any of the +.Fl d +or +.Fl s +options are used on the command line. .It Ev TMPDIR Directory in which to create the working directory when the .Fl d @@ -103,10 +118,6 @@ This variable is used by which will revert to use .Pa /tmp if the variable is not set. -.It Ev SHELL -Used to determine what shell to start if a specific -.Ar shell -is not specified on the command line. .El .Pp .Nm @@ -146,9 +157,9 @@ does not work. Start a new shell in a new temporary directory: .Bd -literal -offset Ds $ shell -shell: INFO: Starting /bin/ksh in /tmp/shell-ksh.mJMHFTFE +shell: info: Starting /bin/ksh in /tmp/shell-ksh.mJMHFTFE $ exit -shell: INFO: Removing /tmp/shell-ksh.mJMHFTFE +shell: info: Removing /tmp/shell-ksh.mJMHFTFE .Ed .Pp Start a new @@ -156,9 +167,9 @@ Start a new shell in a temporary directory: .Bd -literal -offset Ds $ shell dash -shell: INFO: Starting /usr/local/bin/dash in /tmp/shell-dash.V7zU6EtZ +shell: info: Starting /usr/local/bin/dash in /tmp/shell-dash.V7zU6EtZ $ exit -shell: INFO: Removing /tmp/shell-dash.V7zU6EtZ +shell: info: Removing /tmp/shell-dash.V7zU6EtZ .Ed .Pp Start a new @@ -166,10 +177,10 @@ Start a new shell in a specific directory: .Bd -literal -offset Ds $ shell -d "$HOME/testing" bash -shell: INFO: Starting /usr/local/bin/bash in /home/myself/testing +shell: info: Starting /usr/local/bin/bash in /home/myself/testing $ exit exit -shell: INFO: Leaving /home/myself/testing in place +shell: info: Leaving /home/myself/testing in place .Ed .Pp Start @@ -185,8 +196,8 @@ file copied from .Pa $HOME/skel . .Bd -literal -offset Ds $ shell -s "$HOME/skel" ksh -l -shell: INFO: Copying /home/myself/skel into /tmp/shell-ksh.ngEwbcpD -shell: INFO: Starting /bin/ksh in /tmp/shell-ksh.ngEwbcpD +shell: info: Copying /home/myself/skel into /tmp/shell-ksh.ngEwbcpD +shell: info: Starting /bin/ksh in /tmp/shell-ksh.ngEwbcpD $ ls -la total 36 drwxr-xr-x 2 myself wheel 512 Apr 15 12:55 . @@ -199,7 +210,7 @@ drwxrwxrwt 28 root wheel 512 Apr 21 14:15 .. -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 -shell: INFO: Removing /tmp/shell-ksh.ngEwbcpD +shell: info: Removing /tmp/shell-ksh.ngEwbcpD .Ed .Sh SEE ALSO .Xr mktemp 1 diff --git a/doc/shell.txt b/doc/shell.txt index 2d7bc88..fd31125 100644 --- a/doc/shell.txt +++ b/doc/shell.txt @@ -41,7 +41,8 @@ DESCRIPTION conflicts with the -s option. -f Force the execution of the given command, even if it is not a - valid login shell on the current system. + valid login shell on the current system. The command needs to be + specified with an absolute path. -k Keep the temporary directory around after terminating the shell session. @@ -59,13 +60,19 @@ DESCRIPTION ENVIRONMENT shell uses the following environment variables: + SHELL Used to determine what shell to start if a specific shell is not + specified on the command line. If this variable is unset or + empty, then /bin/sh will be used instead. + + SHELL_SKEL + Directory to automatically pre-populate the temporary working + directory with. This environment variable is not used if any of + the -d or -s options are used on the command line. + TMPDIR Directory in which to create the working directory when the -d option is not used. This variable is used by mktemp which will revert to use /tmp if the variable is not set. - SHELL Used to determine what shell to start if a specific shell is not - specified on the command line. - shell clears the environment of the interactive shell that it starts, but also sets the following environment variables: @@ -93,24 +100,24 @@ EXAMPLES Start a new shell in a new temporary directory: $ shell - shell: INFO: Starting /bin/ksh in /tmp/shell-ksh.mJMHFTFE + shell: info: Starting /bin/ksh in /tmp/shell-ksh.mJMHFTFE $ exit - shell: INFO: Removing /tmp/shell-ksh.mJMHFTFE + shell: info: Removing /tmp/shell-ksh.mJMHFTFE Start a new dash shell in a temporary directory: $ shell dash - shell: INFO: Starting /usr/local/bin/dash in /tmp/shell-dash.V7zU6EtZ + shell: info: Starting /usr/local/bin/dash in /tmp/shell-dash.V7zU6EtZ $ exit - shell: INFO: Removing /tmp/shell-dash.V7zU6EtZ + shell: info: Removing /tmp/shell-dash.V7zU6EtZ Start a new bash shell in a specific directory: $ shell -d "$HOME/testing" bash - shell: INFO: Starting /usr/local/bin/bash in /home/myself/testing + shell: info: Starting /usr/local/bin/bash in /home/myself/testing $ exit exit - shell: INFO: Leaving /home/myself/testing in place + 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 @@ -118,8 +125,8 @@ EXAMPLES $HOME/skel. $ shell -s "$HOME/skel" ksh -l - shell: INFO: Copying /home/myself/skel into /tmp/shell-ksh.ngEwbcpD - shell: INFO: Starting /bin/ksh in /tmp/shell-ksh.ngEwbcpD + shell: info: Copying /home/myself/skel into /tmp/shell-ksh.ngEwbcpD + shell: info: Starting /bin/ksh in /tmp/shell-ksh.ngEwbcpD $ ls -la total 36 drwxr-xr-x 2 myself wheel 512 Apr 15 12:55 . @@ -132,7 +139,7 @@ EXAMPLES -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 - shell: INFO: Removing /tmp/shell-ksh.ngEwbcpD + shell: info: Removing /tmp/shell-ksh.ngEwbcpD SEE ALSO mktemp(1) @@ -146,4 +153,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 22, 2018 Unix +Unix July 19, 2018 Unix diff --git a/src/Makefile.in b/src/Makefile.in index cb36513..96c9de4 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -170,7 +170,6 @@ 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/src/shell.in b/src/shell.in index 3723c27..0a5af9b 100644 --- a/src/shell.in +++ b/src/shell.in @@ -23,17 +23,17 @@ perrorf () # We mimic printf here, disable shellcheck warnings. # See https://unix.stackexchange.com/questions/438694 # shellcheck disable=SC2059,SC2145 - printf "$utility_name: ERROR: $@" >&2 + printf "$utility_name: error: $@" >&2 } pinfof () { - # Same as above, but with 'INFO:' instead of 'ERROR:'. Also + # Same as above, but with 'info:' instead of 'info:'. 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 + printf "$utility_name: info: $@" >&2 fi } @@ -138,7 +138,8 @@ while getopts 'd:fks:qv' opt; do k) keep=1 ;; q) quiet=1 ;; s) skel=$OPTARG ;; - v) output_version + v) quiet=0 + output_version exit 0 ;; *) perrorf 'Unknown option on command line\n' exit 1 @@ -149,18 +150,15 @@ shift "$(( OPTIND - 1 ))" if [ -n "$tmpwd" ] && [ -n "$skel" ]; then perrorf 'Can not use both the -d and the -s option at the same time\n' exit 1 +elif [ -z "$tmpwd" ] && [ -z "$skel" ] && [ -n "$SHELL_SKEL" ]; then + skel=$SHELL_SKEL fi if [ -n "$1" ]; then shell="$1" shift else - shell="$SHELL" -fi - -if [ -z "$shell" ]; then - perrorf 'Can not determine what shell to start\n' - exit 1 + shell="${SHELL:-/bin/sh}" fi if [ "$force" -eq 0 ]; then