OSSP CVS Repository

ossp - Check-in [506]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 506
Date: 2001-Jun-14 21:02:54 (local)
2001-Jun-14 19:02:54 (UTC)
User:rse
Branch:
Comment: *** empty log message ***
Tickets:
Inspections:
Files:
ossp-pkg/shtool/ChangeLog      1.157 -> 1.158     7 inserted, 0 deleted
ossp-pkg/shtool/Makefile.in      1.42 -> 1.43     1 inserted, 0 deleted
ossp-pkg/shtool/README      1.79 -> 1.80     1 inserted, 0 deleted
ossp-pkg/shtool/sh.common      added-> 1.18
ossp-pkg/shtool/sh.install      1.21 -> 1.22     3 inserted, 1 deleted
ossp-pkg/shtool/sh.scpp      1.18 -> 1.19     9 inserted, 3 deleted
ossp-pkg/shtool/sh.subst      added-> 1.1
ossp-pkg/shtool/shtool.pod      1.52 -> 1.53     34 inserted, 0 deleted
ossp-pkg/shtool/shtoolize.in      1.23 -> 1.24     1 inserted, 1 deleted
ossp-pkg/shtool/shtoolize.pod      1.6 -> 1.7     1 inserted, 0 deleted

ossp-pkg/shtool/ChangeLog 1.157 -> 1.158

--- ChangeLog    2001/06/14 18:42:36     1.157
+++ ChangeLog    2001/06/14 19:02:54     1.158
@@ -9,6 +9,13 @@
 
  ChangeLog
 
+ Changes between 1.5.4 and 1.6.0 (14-Jun-2001 to xx-Jun-2001):
+
+   *) Add new `shtool subst [-v] [-t] [-n] [-s] [-i] [-b<ext>] 
+      [-e<cmd>] [-f<cmd-file>] [<file>] [...]' command. This
+      is a useful wrapper around sed(1).
+      [Ralf S. Engelschall]
+
  Changes between 1.5.3 and 1.5.4 (19-Apr-2001 to 14-Jun-2001):
 
    *) Removed numerious trailing whitespaces from source files.


ossp-pkg/shtool/Makefile.in 1.42 -> 1.43

--- Makefile.in  2001/06/14 14:24:16     1.42
+++ Makefile.in  2001/06/14 19:02:54     1.43
@@ -55,6 +55,7 @@
  sh.mkshadow \
  sh.fixperm \
  sh.tarball \
+ sh.subst \
  sh.guessos \
  sh.arx \
  sh.slo \


ossp-pkg/shtool/README 1.79 -> 1.80

--- README       2001/06/14 18:42:36     1.79
+++ README       2001/06/14 19:02:54     1.80
@@ -33,6 +33,7 @@
   mkshadow   Make a shadow tree
   fixperm    Fix file permissions inside a source tree
   tarball    Roll distribution tarballs
+  subst      Apply sed(1) substitution operations
   guessos    Simple OS/platform guesser
   arx        Extended archive command
   slo        Separate linker options by library class


ossp-pkg/shtool/sh.common -> 1.18

*** /dev/null    Sat Nov 23 01:25:13 2024
--- -    Sat Nov 23 01:25:28 2024
***************
*** 0 ****
--- 1,160 ----
+ ##
+ ##  This file is part of shtool and free software; you can redistribute
+ ##  it and/or modify it under the terms of the GNU General Public
+ ##  License as published by the Free Software Foundation; either version
+ ##  2 of the License, or (at your option) any later version.
+ ##
+ ##  This file is distributed in the hope that it will be useful,
+ ##  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ##  General Public License for more details.
+ ##
+ ##  You should have received a copy of the GNU General Public License
+ ##  along with this program; if not, write to the Free Software
+ ##  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ ##  USA, or contact Ralf S. Engelschall <rse@engelschall.com>.
+ ##
+ 
+ ##
+ ##  COMMON UTILITY CODE
+ ##
+ 
+ #   commonly used ASCII values
+ ASC_TAB="      "
+ ASC_NL="
+ "
+ 
+ #   determine name of tool
+ if [ ".$tool" != . ]; then
+     #   used inside shtool script
+     toolcmd="$0 $tool"
+     toolcmdhelp="shtool $tool"
+     msgprefix="shtool:$tool"
+ else
+     #   used as standalone script
+     toolcmd="$0"
+     toolcmdhelp="sh $0"
+     msgprefix="$str_tool"
+ fi
+ 
+ #   parse argument specification string
+ eval `echo $arg_spec |\
+       sed -e 's/^\([0-9]*\)\([+=]\)/arg_NUMS=\1; arg_MODE=\2/'`
+ 
+ #   parse option specification string
+ eval `echo h.$opt_spec |\
+       sed -e 's/\([a-zA-Z0-9]\)\([.:+]\)/opt_MODE_\1=\2;/g'`
+ 
+ #   interate over argument line
+ opt_PREV=''
+ while [ $# -gt 0 ]; do
+     #   special option stops processing
+     if [ ".$1" = ".--" ]; then
+         shift
+         break
+     fi
+ 
+     #   determine option and argument
+     opt_ARG_OK=no
+     if [ ".$opt_PREV" != . ]; then
+         #   merge previous seen option with argument
+         opt_OPT="$opt_PREV"
+         opt_ARG="$1"
+         opt_ARG_OK=yes
+         opt_PREV=''
+     else
+         #   split argument into option and argument
+         case "$1" in
+             -[a-zA-Z0-9]*)
+                 eval `echo "x$1" |\
+                       sed -e 's/^x-\([a-zA-Z0-9]\)/opt_OPT="\1";/' \
+                           -e 's/";\(.*\)$/"; opt_ARG="\1"/'`
+                 ;;
+             -[a-zA-Z0-9])
+                 opt_OPT=`echo "x$1" | cut -c3-`
+                 opt_ARG=''
+                 ;;
+             *)
+                 break
+                 ;;
+         esac
+     fi
+ 
+     #   eat up option
+     shift
+ 
+     #   determine whether option needs an argument
+     eval "opt_MODE=\$opt_MODE_${opt_OPT}"
+     if [ ".$opt_ARG" = . -a ".$opt_ARG_OK" != .yes ]; then
+         if [ ".$opt_MODE" = ".:" -o ".$opt_MODE" = ".+" ]; then
+             opt_PREV="$opt_OPT"
+             continue
+         fi
+     fi
+ 
+     #   process option
+     case $opt_MODE in
+         '.' )
+             #   boolean option
+             eval "opt_${opt_OPT}=yes"
+             ;;
+         ':' )
+             #   option with argument (multiple occurances override)
+             eval "opt_${opt_OPT}=\"\$opt_ARG\""
+             ;;
+         '+' )
+             #   option with argument (multiple occurances append)
+             eval "opt_${opt_OPT}=\"\$opt_${opt_OPT}\${ASC_NL}\$opt_ARG\""
+             ;;
+         * )
+             echo "$msgprefix:Error: unknown option: \`-$opt_OPT'" 1>&2
+             echo "$msgprefix:Hint:  run \`$toolcmdhelp -h' or \`man shtool' for details" 1>&2
+             exit 1
+             ;;
+     esac
+ done
+ if [ ".$opt_PREV" != . ]; then
+     echo "$msgprefix:Error: missing argument to option \`-$opt_PREV'" 1>&2
+     echo "$msgprefix:Hint:  run \`$toolcmdhelp -h' or \`man shtool' for details" 1>&2
+     exit 1
+ fi
+ 
+ #   process help option
+ if [ ".$opt_h" = .yes ]; then
+     echo "Usage: $toolcmdhelp $str_usage"
+     exit 0
+ fi
+ 
+ #   complain about incorrect number of arguments
+ case $arg_MODE in
+     '=' )
+         if [ $# -ne $arg_NUMS ]; then
+             echo "$msgprefix:Error: invalid number of arguments (exactly $arg_NUMS expected)" 1>&2
+             echo "$msgprefix:Hint:  run \`$toolcmd -h' or \`man shtool' for details" 1>&2
+             exit 1
+         fi
+         ;;
+     '+' )
+         if [ $# -lt $arg_NUMS ]; then
+             echo "$msgprefix:Error: invalid number of arguments (at least $arg_NUMS expected)" 1>&2
+             echo "$msgprefix:Hint:  run \`$toolcmd -h' or \`man shtool' for details" 1>&2
+             exit 1
+         fi
+         ;;
+ esac
+ 
+ #   establish a temporary file on request
+ if [ ".$gen_tmpfile" = .yes ]; then
+     if [ ".$TMPDIR" != . ]; then
+         tmpdir="$TMPDIR"
+     elif [ ".$TEMPDIR" != . ]; then
+         tmpdir="$TEMPDIR"
+     else
+         tmpdir="/tmp"
+     fi
+     tmpfile="$tmpdir/.shtool.$$"
+     rm -f $tmpfile >/dev/null 2>&1
+     touch $tmpfile
+     chmod 600 $tmpfile
+ fi
+ 


ossp-pkg/shtool/sh.install 1.21 -> 1.22

--- sh.install   2001/06/14 14:24:16     1.21
+++ sh.install   2001/06/14 19:02:54     1.22
@@ -107,7 +107,9 @@
     #   adjust the target file
     if [ ".$opt_e" != . ]; then
         sed='sed'
-        for e in $opt_e; do
+        OIFS="$IFS"; IFS="$ASC_NL"; set -- $opt_e; IFS="$OIFS"
+        for e
+        do
             sed="$sed -e '$e'"
         done
         cp $dsttmp $dsttmp.old


ossp-pkg/shtool/sh.scpp 1.18 -> 1.19

--- sh.scpp      2001/01/17 09:55:11     1.18
+++ sh.scpp      2001/06/14 19:02:54     1.19
@@ -68,10 +68,16 @@
     if [ ".$opt_v" = .yes ]; then
         echo $src | $awk '{ printf(" %s", $0); }' 1>&2
     fi
-    if [ ".$opt_f" = . ]; then
-        inputcmd="cat $src"
+    if [ ".$opt_f" != . ]; then
+        inputcmd="sed"
+        OIFS="$IFS"; IFS="$ASC_NL"; set -- $opt_f; IFS="$OIFS"
+        for e
+        do
+            inputcmd="$inputcmd -e '$e'"
+        done
+        inputcmd="$inputcmd $src"
     else
-        inputcmd="sed $opt_f $src"
+        inputcmd="cat $src"
     fi
     $inputcmd |\
     $awk '


ossp-pkg/shtool/sh.subst -> 1.1

*** /dev/null    Sat Nov 23 01:25:13 2024
--- -    Sat Nov 23 01:25:28 2024
***************
*** 0 ****
--- 1,165 ----
+ ##
+ ##  subst -- Apply sed(1) substitution operations
+ ##  Copyright (c) 2001 Ralf S. Engelschall <rse@engelschall.com>
+ ##  Originally written for OpenPKG's rpmtool
+ ##
+ ##  This file is part of shtool and free software; you can redistribute
+ ##  it and/or modify it under the terms of the GNU General Public
+ ##  License as published by the Free Software Foundation; either version
+ ##  2 of the License, or (at your option) any later version.
+ ##
+ ##  This file is distributed in the hope that it will be useful,
+ ##  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ ##  General Public License for more details.
+ ##
+ ##  You should have received a copy of the GNU General Public License
+ ##  along with this program; if not, write to the Free Software
+ ##  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ ##  USA, or contact Ralf S. Engelschall <rse@engelschall.com>.
+ ##
+ 
+ str_tool="subst"
+ str_usage="[-v] [-t] [-n] [-s] [-i] [-b<ext>] [-e<cmd>] [-f<cmd-file>] [<file>] [...]"
+ gen_tmpfile=yes
+ arg_spec="0+"
+ opt_spec="v.t.n.s.i.b:e+f:"
+ opt_v=no
+ opt_t=no
+ opt_n=no
+ opt_s=no
+ opt_i=no
+ opt_b=""
+ opt_e=""
+ opt_f=""
+ 
+ . ./sh.common
+ 
+ #   remember optional list of file(s)
+ files="$*"
+ 
+ #   parameter consistency check
+ if [ $# -eq 0 -a ".$opt_b" != . ]; then
+     echo "$msgprefix:Error: option -b cannot be applied to stdin" 1>&2
+     exit 1
+ fi
+ if [ $# -eq 0 -a ".$opt_s" = .yes ]; then
+     echo "$msgprefix:Error: option -s cannot be applied to stdin" 1>&2
+     exit 1
+ fi
+ 
+ #   build underlying sed(1) command
+ sedcmd='sed'
+ if [ ".$opt_e" != . ]; then
+     OIFS="$IFS"; IFS="$ASC_NL"; set -- $opt_e; IFS="$OIFS"
+     for e
+     do
+         sedcmd="$sedcmd -e '$e'" 
+     done
+ elif [ ".$opt_f" != . ]; then
+     if [ ! -f $opt_f ]; then
+         echo "$msgprefix:Error: command file \`$opt_f' not found" 1>&2
+         exit 1
+     fi
+     sedcmd="$sedcmd -f '$opt_f'"
+ else
+     echo "$msgprefix:Error: either -e option(s) or -f option required" 1>&2
+     exit 1
+ fi
+ 
+ #   determine extension for original file
+ orig=".orig"
+ if [ ".$opt_b" != . ]; then
+     orig="$opt_b"
+ fi
+ 
+ #   apply sed(1) operation(s)
+ if [ ".$files" != . ]; then
+     #   apply operation(s) to files
+     for file in $files; do
+         test ".$file" = . && continue
+         if [ ! -f $file ]; then
+             echo "$msgprefix:Warning: file \`$file' not found" 1>&2
+             continue
+         fi
+ 
+         #   handle interactive mode
+         if [ ".$opt_i" = .yes ]; then
+             eval "$sedcmd <$file >$file.new"
+             skip=no
+             if cmp $file $file.new >/dev/null 2>&1; then
+                 rm -f $file.new
+                 skip=yes
+             else
+                 (diff -u1 $file $file.new >$tmpfile) 2>/dev/null
+                 if [ ".`cat $tmpfile`" = . ]; then
+                     (diff -C1 $file $file.new >$tmpfile) 2>/dev/null
+                     if [ ".`cat $tmpfile`" = . ]; then
+                         echo "$msgprefix:Warning: unable to show difference for file \`$file'" 1>&2
+                         cp /dev/null $tmpfile
+                     fi
+                 fi
+                 rm -f $file.new
+                 cat $tmpfile
+                 echo dummy | awk '{ printf("%s", TEXT); }' TEXT=">>> Apply [Y/n]: "
+                 read input
+                 if [ ".$input" != .Y ] &&\
+                    [ ".$input" != .y ] &&\
+                    [ ".$input" != . ]; then
+                    skip=yes
+                 fi
+             fi
+             if [ ".$skip" = .yes ]; then
+                 if [ ".$opt_v" = .yes ]; then
+                     echo "file \`$file' -- skipped" 1>&2
+                 fi
+                 continue
+             fi
+         fi
+ 
+         #   apply sed(1) operation(s)
+         if [ ".$opt_v" = .yes ]; then
+             echo "patching \`$file'" 1>&2
+         fi
+         if [ ".$opt_t" = .yes ]; then
+             echo "\$ cp -p $file $file$orig"
+             echo "\$ $sedcmd <$file$orig >$file"
+         fi
+         if [ ".$opt_n" = .no ]; then
+             cp -p $file $file$orig
+             eval "$sedcmd <$file$orig >$file"
+         fi
+ 
+         #   optionally fix timestamp
+         if [ ".$opt_s" = .yes ]; then
+             if [ ".$opt_t" = .yes ]; then
+                 echo "\$ touch -r $file$orig $file"
+             fi
+             if [ ".$opt_n" = .no ]; then
+                 touch -r $file$orig $file
+             fi
+         fi
+ 
+         #   optionally remove preserved original file
+         if [ ".$opt_b" = . ]; then
+             if [ ".$opt_t" = .yes ]; then
+                 echo "\$ rm -f $file$orig"
+             fi
+             if [ ".$opt_n" = .no ]; then
+                 rm -f $file$orig
+             fi
+         fi
+     done
+ else
+     #   apply operation(s) to stdin/stdout
+     if [ ".$opt_v" = .yes ]; then
+         echo "patching <stdin>" 1>&2
+     fi
+     if [ ".$opt_t" = .yes ]; then
+         echo "\$ $sedcmd"
+     fi
+     if [ ".$opt_n" = .no ]; then
+         eval "$sedcmd"
+     fi
+ fi
+ 


ossp-pkg/shtool/shtool.pod 1.52 -> 1.53

--- shtool.pod   2001/06/14 14:24:16     1.52
+++ shtool.pod   2001/06/14 19:02:54     1.53
@@ -250,6 +250,10 @@
 
 Roll standardized distribution tarballs.
 
+=item B<subst>
+
+Apply sed(1) substitution operations.
+
 =item B<guessos>
 
 Simple operating system and platform architecture guesser which
@@ -555,6 +559,36 @@
       shtool tarball -o foobar-$$V.tar.gz -c 'gzip -9' \
                      -u bar -g gnu -e 'CVS,\.cvsignore' .
 
+=item B<subst> [B<-v>] [B<-t>] [B<-n>] [B<-s>] [B<-i>] [B<-b> I<ext>] [B<-e> I<cmd>] [B<-f> I<cmd-file>] [I<file>] [I<file> ...]
+
+This command applies one or more sed(1) substitution operations to
+F<stdin> or any number of files. The sed(1) operations are either
+specified on the command line with option ``B<-e>'' or are contained
+in a file I<cmd-file> and are specified with option ``B<-f>''. The
+original untouched I<file> is usually overridden. If option ``B<-b>''
+is given and specifies a file extension, the original file is preserved
+as ``I<file>.I<ext>''. If option ``B<-s>'' (stealth) is specified,
+the timestamp is preserved on I<file>, too. Option ``B<-i>'' enables
+interactive mode where the user has to approve each operation. Option
+``B<-n>'' (no operation) can be used to disable the actual execution of
+the essential shell commands which would be executed. Option ``B<-t>''
+(trace) can be used to enable the output of the essential shell commands
+which are executed. Option ``B<-v>'' (verbose) can be used to display
+the files which are patched.
+
+Example:
+
+  #    interactive shell
+  $ shtool subst -i -e 's;(c) \([0-9]*\)-2000;(c) \1-2001;' *.[ch]
+
+  #    RPM spec-file
+  %install
+      shtool subst -v -n \
+          -e 's;^\(prefix=\).*;\1 $RPM_BUILD_ROOT%{_prefix};g' \
+          -e 's;^\(sysconfdir=\).*;\1 $RPM_BUILD_ROOT%{_prefix}/etc;g' \
+          `find . -name Makefile -print`
+      make install
+
 =item B<guessos>
 
 This command is a simple operating system and platform architecture guesser


ossp-pkg/shtool/shtoolize.in 1.23 -> 1.24

--- shtoolize.in 2001/06/14 14:24:17     1.23
+++ shtoolize.in 2001/06/14 19:02:54     1.24
@@ -35,7 +35,7 @@
 #   Available modules
 my @available = qw(
     echo mdate table prop move install mkdir mkln mkshadow
-    fixperm tarball guessos arx slo scpp version path
+    fixperm tarball subst guessos arx slo scpp version path
 );
 
 ##


ossp-pkg/shtool/shtoolize.pod 1.6 -> 1.7

--- shtoolize.pod        2001/06/14 14:24:17     1.6
+++ shtoolize.pod        2001/06/14 19:02:54     1.7
@@ -54,6 +54,7 @@
  mkshadow   Make a shadow tree
  fixperm    Fix file permissions inside a source tree
  tarball    Roll distribution tarballs
+ subst      Apply sed(1) substitution operations
  guessos    Simple OS/platform guesser
  arx        Extended archive command
  slo        Separate linker options by library class

CVSTrac 2.0.1