readded udpated scripts directory

This commit is contained in:
tomit4 2022-06-09 12:59:03 -07:00
parent cd053a412a
commit f3117c81d9
84 changed files with 3210 additions and 0 deletions

27
scripts/ow_v1.sh Executable file
View file

@ -0,0 +1,27 @@
#!/bin/sh
# overwrite: copy standard intput to output after EOF
# version 1. BUG here
PATH=/bin:/usr/bin
case $# in
1) ;;
*) echo `Usage: overwrite file` 1>&2; exit 2
esac
new=/tmp/overwr.$$
trap `rm -f $new; exit 1` 1 2 15
cat >$new # collect the input
cp $new $1 # overwrite the input file
rm -f $new
# this file is used solely as a first example of how to think about
# programming in the shell language.
# cp is used instead of mv so the permissions and owner of the output file aren'the
# changed if it already exist.
# Appealingly simple as this version is, it has a fatal flaw: if the user types
# DEL during the cp, the original input file will be ruined. We must prevent and
# interrupt from stopping the overwriting of the input file. (see ow_v2.sh)