--- sh.subst 2004/05/08 19:09:58 1.13
+++ sh.subst 2004/07/02 13:06:36 1.14
@@ -19,14 +19,15 @@
##
str_tool="subst"
-str_usage="[-v|--verbose] [-t|--trace] [-n|--nop] [-q|--quiet] [-s|--stealth] [-i|--interactive] [-b|--backup <ext>] [-e|--exec <cmd>] [-f|--file <cmd-file>] [<file>] [...]"
+str_usage="[-v|--verbose] [-t|--trace] [-n|--nop] [-w|--warning] [-q|--quiet] [-s|--stealth] [-i|--interactive] [-b|--backup <ext>] [-e|--exec <cmd>] [-f|--file <cmd-file>] [<file>] [...]"
gen_tmpfile=yes
arg_spec="0+"
-opt_spec="v.t.n.q.s.i.b:e+f:"
-opt_alias="v:verbose,t:trace,n:nop,q:quiet,s:stealth,i:interactive,b:backup,e:exec,f:file"
+opt_spec="v.t.n.w.q.s.i.b:e+f:"
+opt_alias="v:verbose,t:trace,n:nop,w:warning,q:quiet,s:stealth,i:interactive,b:backup,e:exec,f:file"
opt_v=no
opt_t=no
opt_n=no
+opt_w=no
opt_q=no
opt_s=no
opt_i=no
@@ -38,6 +39,7 @@
# remember optional list of file(s)
files="$*"
+files_num="$#"
# parameter consistency check
if [ $# -eq 0 ] && [ ".$opt_b" != . ]; then
@@ -77,6 +79,7 @@
# apply sed(1) operation(s)
if [ ".$files" != . ]; then
# apply operation(s) to files
+ substdone=no
for file in $files; do
test ".$file" = . && continue
if [ ! -f $file ]; then
@@ -146,7 +149,11 @@
# optionally check whether any content change actually occurred
if [ ".$opt_q" = .no ]; then
if cmp $file$orig $file >/dev/null 2>&1; then
- echo "$msgprefix:Warning: substitution operation results in no content change" 1>&2
+ if [ ".$opt_w" = .yes ]; then
+ echo "$msgprefix:Warning: substitution resulted in no content change on file \"$file\"" 1>&2
+ fi
+ else
+ substdone=yes
fi
fi
@@ -160,6 +167,15 @@
fi
fi
done
+ if [ ".$opt_q" = .no ] && [ ".$opt_w" = .no ]; then
+ if [ ".$substdone" = .no ]; then
+ if [ ".$files_num" = .1 ]; then
+ echo "$msgprefix:Warning: substitution resulted in no content change on file \"$file\"" 1>&2
+ else
+ echo "$msgprefix:Warning: substitution resulted in no content change on any file" 1>&2
+ fi
+ fi
+ fi
else
# apply operation(s) to stdin/stdout
if [ ".$opt_v" = .yes ]; then
@@ -191,6 +207,7 @@
[B<-v>|B<--verbose>]
[B<-t>|B<--trace>]
[B<-n>|B<--nop>]
+[B<-w>|B<--warning>]
[B<-q>|B<--quiet>]
[B<-s>|B<--stealth>]
[B<-i>|B<--interactive>]
@@ -223,6 +240,12 @@
No operation mode. Actual execution of the essential shell commands
which would be executed is suppressed.
+=item B<-w>, B<--warning>
+
+Show warning on substitution operation resulting in no content change
+on I<every> file. The default is to show a warning on substitution
+operations resulted in no content change on I<all> files.
+
=item B<-q>, B<--quiet>
Suppress warning on substitution operation resulting in no content change.
|