Skip to content

Commit

Permalink
INIT: remove 'ignore' and 'silent' stub scripts
Browse files Browse the repository at this point in the history
These are stub scripts to deal with mamake prefix artefacts in the
Mamfiles. The 'ignore' script runs the command (after exporting
variables indicated by arguments containing a '=', if any) and
returns status zero regardless of the result of the command. The
'silent' script does the same but keeps the exit status. (In spite
of what its name might suggest, it does suppress any output.)

The Mamfiles contain several places where 'silent' is used, and
those prefixes can simply be removed -- whereas 'ignore' is
currently unused.

bin/ignore, src/cmd/INIT/ignore.sh,
bin/silent, src/cmd/INIT/silent.sh:
- Removed.

src/cmd/INIT/mamake.c: run():
- To keep backwards compatibility while still getting rid of
  clutter, add silent() and ignore() stub functions to the common
  prefix code for 'exec -' shell action scripts; this should allow
  any backported old Mamfile code to continue to run.
- Remove 'trap - 1 2 3 15'. The script is executed as a -c script
  (via execute()), so all traps are already initialised as default.

src/*/*/Mamfile:
- Remove 'silent' prefixes.
- Remove no-op 'test -d . || mkdir .'.
  • Loading branch information
McDutchie committed Oct 26, 2022
1 parent 1ae6988 commit 1aecc1b
Show file tree
Hide file tree
Showing 15 changed files with 87 additions and 281 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ FEATURE/
/src/cmd/INIT/execrate
/src/cmd/INIT/filter
/src/cmd/INIT/iffe
/src/cmd/INIT/ignore
/src/cmd/INIT/mamake
/src/cmd/INIT/mamprobe
/src/cmd/INIT/mktest
Expand All @@ -42,7 +41,6 @@ FEATURE/
/src/cmd/INIT/probe.sh
/src/cmd/INIT/regress
/src/cmd/INIT/rt
/src/cmd/INIT/silent
/src/cmd/builtin/pty
/src/cmd/ksh93/ksh
/src/cmd/ksh93/shcomp
Expand Down
33 changes: 0 additions & 33 deletions bin/ignore

This file was deleted.

2 changes: 1 addition & 1 deletion bin/package
Original file line number Diff line number Diff line change
Expand Up @@ -1842,7 +1842,7 @@ case $x in
then
# update the basic package commands

for i in execrate ignore mamprobe silent
for i in execrate mamprobe
do test -h $PACKAGEROOT/bin/$i 2>/dev/null ||
case $(ls -t $INITROOT/$i.sh $PACKAGEROOT/bin/$i 2>/dev/null) in
"$INITROOT/$i.sh"*)
Expand Down
32 changes: 0 additions & 32 deletions bin/silent

This file was deleted.

86 changes: 0 additions & 86 deletions src/cmd/INIT/Mamfile
Original file line number Diff line number Diff line change
Expand Up @@ -231,84 +231,6 @@ make install
exec - esac
exec - test -w execrate -a -x execrate || chmod u+w,+x execrate
done execrate generated
make ignore
make ignore.sh
done ignore.sh
prev ignore.sh
exec - case static,port:$OPTIND:$RANDOM in
exec - ?*:*:*|*::*|*:*:$RANDOM)
exec - ;;
exec - *) if ENV= LC_ALL=C x= $SHELL -nc '[[ a || b ]] && : ${list[level]} !(pattern)' 2>/dev/null
exec - then if grep '### .*archaic.* ###' >/dev/null
exec - then : ignore contains archaic constructs :
exec - else ENV= LC_ALL=C $SHELL -n ignore.sh
exec - fi
exec - fi
exec - ;;
exec - esac
exec - case '${mam_cc_SHELLMAGIC}' in
exec - "") case 0 in
exec - 0) cp ignore.sh ignore
exec - ;;
exec - *) {
exec - i=`(read x; echo $x) < ignore.sh`
exec - case $i in
exec - '#!'*|*'||'*|':'*|'":"'*|"':'"*) echo "$i" ;;
exec - esac
exec - cat - ignore.sh <<'!'
exec -
exec - !
exec - } > ignore
exec - ;;
exec - esac
exec - ;;
exec - *) cat - ignore.sh > ignore <<'!'
exec - ${mam_cc_SHELLMAGIC}
exec -
exec - !
exec - ;;
exec - esac
exec - test -w ignore -a -x ignore || chmod u+w,+x ignore
done ignore generated
make silent
make silent.sh
done silent.sh
prev silent.sh
exec - case static,port:$OPTIND:$RANDOM in
exec - ?*:*:*|*::*|*:*:$RANDOM)
exec - ;;
exec - *) if ENV= LC_ALL=C x= $SHELL -nc '[[ a || b ]] && : ${list[level]} !(pattern)' 2>/dev/null
exec - then if grep '### .*archaic.* ###' >/dev/null
exec - then : silent contains archaic constructs :
exec - else ENV= LC_ALL=C $SHELL -n silent.sh
exec - fi
exec - fi
exec - ;;
exec - esac
exec - case '${mam_cc_SHELLMAGIC}' in
exec - "") case 0 in
exec - 0) cp silent.sh silent
exec - ;;
exec - *) {
exec - i=`(read x; echo $x) < silent.sh`
exec - case $i in
exec - '#!'*|*'||'*|':'*|'":"'*|"':'"*) echo "$i" ;;
exec - esac
exec - cat - silent.sh <<'!'
exec -
exec - !
exec - } > silent
exec - ;;
exec - esac
exec - ;;
exec - *) cat - silent.sh > silent <<'!'
exec - ${mam_cc_SHELLMAGIC}
exec -
exec - !
exec - ;;
exec - esac
exec - test -w silent -a -x silent || chmod u+w,+x silent
done silent generated
make mamake
make mamake.o
make mamake.c
Expand Down Expand Up @@ -436,10 +358,6 @@ make install
prev execrate
exec - ${STDCMP} 2>/dev/null -s execrate ${PACKAGEROOT}/bin/execrate || { ${STDMV} ${PACKAGEROOT}/bin/execrate ${PACKAGEROOT}/bin/execrate.old 2>/dev/null || true; ${STDCP} execrate ${PACKAGEROOT}/bin/execrate ;}
done ${PACKAGEROOT}/bin/execrate generated
make ${PACKAGEROOT}/bin/ignore
prev ignore
exec - ${STDCMP} 2>/dev/null -s ignore ${PACKAGEROOT}/bin/ignore || { ${STDMV} ${PACKAGEROOT}/bin/ignore ${PACKAGEROOT}/bin/ignore.old 2>/dev/null || true; ${STDCP} ignore ${PACKAGEROOT}/bin/ignore ;}
done ${PACKAGEROOT}/bin/ignore generated
make ${PACKAGEROOT}/bin/mamprobe
make mamprobe
make mamprobe.sh
Expand Down Expand Up @@ -485,10 +403,6 @@ make install
prev package
exec - ${STDCMP} 2>/dev/null -s package ${PACKAGEROOT}/bin/package || { ${STDMV} ${PACKAGEROOT}/bin/package ${PACKAGEROOT}/bin/package.old 2>/dev/null || true; ${STDCP} package ${PACKAGEROOT}/bin/package ;}
done ${PACKAGEROOT}/bin/package generated
make ${PACKAGEROOT}/bin/silent
prev silent
exec - ${STDCMP} 2>/dev/null -s silent ${PACKAGEROOT}/bin/silent || { ${STDMV} ${PACKAGEROOT}/bin/silent ${PACKAGEROOT}/bin/silent.old 2>/dev/null || true; ${STDCP} silent ${PACKAGEROOT}/bin/silent ;}
done ${PACKAGEROOT}/bin/silent generated
make ${INSTALLROOT}/bin/crossexec
prev crossexec
exec - ${STDCMP} 2>/dev/null -s crossexec ${INSTALLROOT}/bin/crossexec || { ${STDMV} ${INSTALLROOT}/bin/crossexec ${INSTALLROOT}/bin/crossexec.old 2>/dev/null || true; ${STDCP} crossexec ${INSTALLROOT}/bin/crossexec ;}
Expand Down
33 changes: 0 additions & 33 deletions src/cmd/INIT/ignore.sh

This file was deleted.

28 changes: 26 additions & 2 deletions src/cmd/INIT/mamake.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* coded for portability
*/

#define RELEASE_DATE "2022-07-15"
#define RELEASE_DATE "2022-10-26"
static char id[] = "\n@(#)$Id: mamake (ksh 93u+m) " RELEASE_DATE " $\0\n";

#if _PACKAGE_ast
Expand Down Expand Up @@ -1220,7 +1220,31 @@ run(Rule_t* r, register char* s)
else
x = state.exec;
if (x)
append(buf, "trap - 1 2 3 15\nPATH=.:$PATH\nset -x\n");
append(buf,
/* stub for nmake's silent prefix (for backward compat) */
"silent()\n"
"(\n"
"while test \"$#\" -gt 0\n"
"do case $1 in\n"
"*=*) export \"$1\"; shift;;\n"
"*) break;;\n"
"esac\n"
"done\n"
"\"$@\"\n"
")\n"
/* stub for nmake's ignore prefix (for backward compat) */
"ignore()\n"
"{\n"
"silent \"$@\" || :\n" /* always return status 0 */
"}\n"
/* find commands in the current working directory first */
"case $PATH in\n"
".:*) ;;\n"
"*) PATH=.:$PATH;;\n"
"esac\n"
/* show trace for the shell action commands */
"set -x\n"
);
if (state.view)
{
do
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/INIT/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1842,7 +1842,7 @@ case $x in
then
# update the basic package commands

for i in execrate ignore mamprobe silent
for i in execrate mamprobe
do test -h $PACKAGEROOT/bin/$i 2>/dev/null ||
case $(ls -t $INITROOT/$i.sh $PACKAGEROOT/bin/$i 2>/dev/null) in
"$INITROOT/$i.sh"*)
Expand Down
32 changes: 0 additions & 32 deletions src/cmd/INIT/silent.sh

This file was deleted.

4 changes: 2 additions & 2 deletions src/cmd/builtin/Mamfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ make install
exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -o pty pty.o ${mam_libutil} ${mam_libast} -lm ${mam_libcmd}
done pty generated
make ${INSTALLROOT}/bin
exec - if silent test ! -d ${INSTALLROOT}/bin
exec - if test ! -d ${INSTALLROOT}/bin
exec - then mkdir -p ${INSTALLROOT}/bin
exec - fi
done ${INSTALLROOT}/bin generated
Expand All @@ -57,7 +57,7 @@ make install
exec - ${STDCMP} 2>/dev/null -s pty ${INSTALLROOT}/bin/pty || { ${STDMV} ${INSTALLROOT}/bin/pty ${INSTALLROOT}/bin/pty.old 2>/dev/null || true; ${STDCP} pty ${INSTALLROOT}/bin/pty ;}
done ${INSTALLROOT}/bin/pty generated
make ${INSTALLROOT}/bin
exec - if silent test ! -d ${INSTALLROOT}/bin
exec - if test ! -d ${INSTALLROOT}/bin
exec - then mkdir -p ${INSTALLROOT}/bin
exec - fi
done ${INSTALLROOT}/bin virtual
Expand Down
14 changes: 7 additions & 7 deletions src/cmd/ksh93/Mamfile
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,7 @@ make install
done shell virtual
prev libshell.a archive
make ${INSTALLROOT}/bin
exec - if silent test ! -d ${INSTALLROOT}/bin
exec - if test ! -d ${INSTALLROOT}/bin
exec - then mkdir -p ${INSTALLROOT}/bin
exec - fi
done ${INSTALLROOT}/bin generated
Expand All @@ -1386,7 +1386,7 @@ make install
exec - ${STDCMP} 2>/dev/null -s ksh ${INSTALLROOT}/bin/ksh || { ${STDMV} ${INSTALLROOT}/bin/ksh ${INSTALLROOT}/bin/ksh.old 2>/dev/null || true; ${STDCP} ksh ${INSTALLROOT}/bin/ksh ;}
done ${INSTALLROOT}/bin/ksh generated
make ${INSTALLROOT}/man/man1
exec - if silent test ! -d ${INSTALLROOT}/man/man1
exec - if test ! -d ${INSTALLROOT}/man/man1
exec - then mkdir -p ${INSTALLROOT}/man/man1
exec - fi
done ${INSTALLROOT}/man/man1 generated
Expand All @@ -1397,7 +1397,7 @@ make install
exec - ${STDCMP} 2>/dev/null -s sh.1 ${INSTALLROOT}/man/man1/sh.1 || { ${STDMV} ${INSTALLROOT}/man/man1/sh.1 ${INSTALLROOT}/man/man1/sh.1.old 2>/dev/null || true; ${STDCP} sh.1 ${INSTALLROOT}/man/man1/sh.1 ;}
done ${INSTALLROOT}/man/man1/sh.1 generated
make ${INSTALLROOT}/lib
exec - if silent test ! -d ${INSTALLROOT}/lib
exec - if test ! -d ${INSTALLROOT}/lib
exec - then mkdir -p ${INSTALLROOT}/lib
exec - fi
done ${INSTALLROOT}/lib generated
Expand All @@ -1408,7 +1408,7 @@ make install
exec - (ranlib ${INSTALLROOT}/lib/libshell.a) >/dev/null 2>&1 || true
done ${INSTALLROOT}/lib/libshell.a generated
make ${INSTALLROOT}/man/man3
exec - if silent test ! -d ${INSTALLROOT}/man/man3
exec - if test ! -d ${INSTALLROOT}/man/man3
exec - then mkdir -p ${INSTALLROOT}/man/man3
exec - fi
done ${INSTALLROOT}/man/man3 generated
Expand All @@ -1424,7 +1424,7 @@ make install
exec - ${STDCMP} 2>/dev/null -s nval.3 ${INSTALLROOT}/man/man3/nval.3 || { ${STDMV} ${INSTALLROOT}/man/man3/nval.3 ${INSTALLROOT}/man/man3/nval.3.old 2>/dev/null || true; ${STDCP} nval.3 ${INSTALLROOT}/man/man3/nval.3 ;}
done ${INSTALLROOT}/man/man3/nval.3 generated
make ${INSTALLROOT}/lib/lib
exec - if silent test ! -d ${INSTALLROOT}/lib/lib
exec - if test ! -d ${INSTALLROOT}/lib/lib
exec - then mkdir -p ${INSTALLROOT}/lib/lib
exec - fi
done ${INSTALLROOT}/lib/lib generated
Expand All @@ -1434,7 +1434,7 @@ make install
exec - ${STDCMP} 2>/dev/null -s shell.req ${INSTALLROOT}/lib/lib/shell || { ${STDMV} ${INSTALLROOT}/lib/lib/shell ${INSTALLROOT}/lib/lib/shell.old 2>/dev/null || true; ${STDCP} shell.req ${INSTALLROOT}/lib/lib/shell ;}
done ${INSTALLROOT}/lib/lib/shell generated
make ${PACKAGE_ast_INCLUDE}
exec - if silent test ! -d ${PACKAGE_ast_INCLUDE}
exec - if test ! -d ${PACKAGE_ast_INCLUDE}
exec - then mkdir -p ${PACKAGE_ast_INCLUDE}
exec - fi
done ${PACKAGE_ast_INCLUDE} generated
Expand Down Expand Up @@ -1466,7 +1466,7 @@ make install
exec - ${STDCMP} 2>/dev/null -s shcomp ${INSTALLROOT}/bin/shcomp || { ${STDMV} ${INSTALLROOT}/bin/shcomp ${INSTALLROOT}/bin/shcomp.old 2>/dev/null || true; ${STDCP} shcomp ${INSTALLROOT}/bin/shcomp ;}
done ${INSTALLROOT}/bin/shcomp generated
make ${INSTALLROOT}/fun
exec - if silent test ! -d ${INSTALLROOT}/fun
exec - if test ! -d ${INSTALLROOT}/fun
exec - then mkdir -p ${INSTALLROOT}/fun
exec - fi
done ${INSTALLROOT}/fun generated
Expand Down
Loading

0 comments on commit 1aecc1b

Please sign in to comment.