diff --git a/ChangeLog b/ChangeLog index 97ae6360b..a9ea9a3bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2002-11-01 Pavel Roskin + + * configure.in: Don't substitute mc.sh and mc.csh - it's now + done ... + * lib/Makefile.am: ... here. Add wrappers for mc to avoid + defining complex shell scripts in functions and aliases. + * lib/mc-wrapper.csh.in: New file - template for the script + that runs mc and changes directory in csh. + * lib/mc-wrapper.sh.in: New file - template for the script + that runs mc and changes directory in sh. + 2002-11-01 Andrew V. Samoilov * doc/mc.1.in (Keys): Document S-. diff --git a/configure.in b/configure.in index 011b1d0e5..a9e4629a4 100644 --- a/configure.in +++ b/configure.in @@ -577,8 +577,6 @@ pc/Makefile m4/Makefile lib/mc.ext -lib/mc.sh -lib/mc.csh vfs/extfs/deb vfs/extfs/ftplist diff --git a/lib/Makefile.am b/lib/Makefile.am index 5e193dd01..9ad99e6a9 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -18,11 +18,13 @@ noinst_DATA = \ noinst_SCRIPTS = tdiff -suppbin_SCRIPTS = mc.csh mc.sh +suppbin_SCRIPTS = mc.csh mc.sh mc-wrapper.csh mc-wrapper.sh ti_DATA = README.xterm linux.ti xterm.ad xterm.ti ansi.ti vt100.ti xterm.tcap pkgdata_DATA = $(LIBFILES_CONST) $(LIBFILES_ADD) $(LIBFILES_OUT) +CLEANFILES = $(suppbin_SCRIPTS) + # Files processed by configure don't need to be here EXTRA_DIST = \ $(LIBFILES_CONST) \ @@ -31,3 +33,15 @@ EXTRA_DIST = \ $(noinst_SCRIPTS) \ mc.charsets +mc.csh: mc.csh.in + sed "s%@""suppbindir@%$(suppbindir)%" mc.csh.in > mc.csh + +mc.sh: mc.sh.in + sed "s%@""suppbindir@%$(suppbindir)%" mc.sh.in > mc.sh + +mc-wrapper.csh: mc-wrapper.csh.in + sed "s%@""bindir@%$(bindir)%" mc-wrapper.csh.in > mc-wrapper.csh + +mc-wrapper.sh: mc-wrapper.sh.in + sed "s%@""bindir@%$(bindir)%" mc-wrapper.sh.in > mc-wrapper.sh + diff --git a/lib/mc-wrapper.csh.in b/lib/mc-wrapper.csh.in new file mode 100644 index 000000000..226592756 --- /dev/null +++ b/lib/mc-wrapper.csh.in @@ -0,0 +1,20 @@ +#! /bin/csh + +if ($?TMPDIR) then + setenv MC_PWD_FILE $TMPDIR/mc-$USER/mc.pwd.$$ +else + setenv MC_PWD_FILE /tmp/mc-$USER/mc.pwd.$$ +endif + +@bindir@/mc -P "$MC_PWD_FILE" $* + +if (-r "$MC_PWD_FILE") then + setenv MC_PWD "`cat $MC_PWD_FILE`" + if ( -d "$MC_PWD" ) then + cd "$MC_PWD" + endif + unsetenv MC_PWD +endif + +rm -f "$MC_PWD_FILE" +unsetenv MC_PWD_FILE diff --git a/lib/mc-wrapper.sh.in b/lib/mc-wrapper.sh.in new file mode 100644 index 000000000..c286ebb61 --- /dev/null +++ b/lib/mc-wrapper.sh.in @@ -0,0 +1,15 @@ +#! /bin/sh + +MC_PWD_FILE="${TMPDIR-/tmp}/mc-$USER/mc.pwd.$$" +@bindir@/mc -P "$MC_PWD_FILE" "$@" + +if test -r "$MC_PWD_FILE"; then + MC_PWD="`cat $MC_PWD_FILE`" + if test -n "$MC_PWD" && test -d "$MC_PWD"; then + cd "$MC_PWD" + fi + unset MC_PWD +fi + +rm -f "$MC_PWD_FILE" +unset MC_PWD_FILE diff --git a/lib/mc.csh.in b/lib/mc.csh.in index 80176c287..e3a64431e 100644 --- a/lib/mc.csh.in +++ b/lib/mc.csh.in @@ -1 +1 @@ -alias mc 'setenv MC_PWD_FILE /tmp/mc-$USER/mc.pwd.$$; @prefix@/bin/mc -P "$MC_PWD_FILE" \!*; if -r "$MC_PWD_FILE" cd "`cat $MC_PWD_FILE`"; rm -f "$MC_PWD_FILE"; unsetenv MC_PWD_FILE' +alias mc 'source @suppbindir@/mc-wrapper.csh \!*' diff --git a/lib/mc.sh.in b/lib/mc.sh.in index 14d4fcd1a..8c1b26b6f 100644 --- a/lib/mc.sh.in +++ b/lib/mc.sh.in @@ -1,18 +1 @@ -mc () -{ - MC_PWD_FILE="${TMPDIR-/tmp}/mc-$USER/mc.pwd.$$" - @prefix@/bin/mc -P "$MC_PWD_FILE" "$@" - if test -r "$MC_PWD_FILE"; then - MC_PWD="`cat $MC_PWD_FILE`" - if test -n "$MC_PWD" && test -d "$MC_PWD"; then - cd "$MC_PWD" - fi - fi - rm -f "$MC_PWD_FILE" - unset MC_PWD - unset MC_PWD_FILE -} - -if test -n "$BASH_VERSION"; then - export -f mc -fi +alias mc='. @suppbindir@/mc-wrapper.sh "$@"'