mirror of https://github.com/MidnightCommander/mc
Ticket #2947: mc.menu: quoting and whitespace fixes
`$*` must be quoted unless it's a command `%*` must not quoted (already quoted) 1) quoting fixes 2) indentation fixes 3) `while` replaced by `for` loops 4) header comment (taken from source code) Signed-off-by: Andreas Mohr <and@gmx.li> Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
This commit is contained in:
parent
b9a78aea36
commit
becc0d01d0
238
misc/mc.menu.in
238
misc/mc.menu.in
|
@ -1,4 +1,27 @@
|
|||
shell_patterns=0
|
||||
|
||||
##############################################################################
|
||||
# %% The % character
|
||||
# %f The current file (if non-local vfs, file will be copied locally and
|
||||
# %f will be full path to it)
|
||||
# %p The current file
|
||||
# %d The current working directory
|
||||
# %s "Selected files"; the tagged files if any, otherwise the current file
|
||||
# %t Tagged files
|
||||
# %u Tagged files (and they are untagged on return from expand_format)
|
||||
# %view Runs the commands and pipes standard output to the view command
|
||||
# If %view is immediately followed by '{', recognize keywords
|
||||
# ascii, hex, nroff and unform
|
||||
#
|
||||
# If the format letter is in uppercase, it refers to the other panel
|
||||
#
|
||||
# With a number followed the % character you can turn quoting on (default)
|
||||
# and off. For example:
|
||||
# %f quote expanded macro
|
||||
# %1f ditto
|
||||
# %0f don't quote expanded macro
|
||||
##############################################################################
|
||||
|
||||
+ ! t t
|
||||
@ Do something on the current file
|
||||
CMD=%{Enter command}
|
||||
|
@ -6,17 +29,15 @@ shell_patterns=0
|
|||
|
||||
+ t t
|
||||
@ Do something on the tagged files
|
||||
set %t; CMD=%{Enter command}
|
||||
while [ -n "$1" ]; do
|
||||
$CMD "$1"
|
||||
shift
|
||||
CMD=%{Enter command}
|
||||
for i in %t ; do
|
||||
$CMD "$i"
|
||||
done
|
||||
|
||||
|
||||
0 Edit a bug report and send it to root
|
||||
I=`mktemp "${MC_TMPDIR:-/tmp}/mail.XXXXXX"` || exit 1
|
||||
${EDITOR-vi} "$I"
|
||||
test -r $I && mail root < $I
|
||||
test -r "$I" && mail root < "$I"
|
||||
rm -f "$I"
|
||||
|
||||
=+ f \.1$ | f \.3$ | f \.4$ | f \.5$ | f \.6$ | f \.7$ | f \.8$ | f \.man$ & t r
|
||||
|
@ -31,7 +52,7 @@ shell_patterns=0
|
|||
Pwd=`basename %d /`
|
||||
echo -n "Name of the compressed file (without extension) [$Pwd]: "
|
||||
read tar
|
||||
if [ "$tar"x = x ]; then tar="$Pwd"; fi
|
||||
[ "$tar"x = x ] && tar="$Pwd"
|
||||
cd .. && \
|
||||
tar cf - "$Pwd" | gzip -f9 > "$tar.tar.gz" && \
|
||||
echo "../$tar.tar.gz created."
|
||||
|
@ -40,7 +61,7 @@ shell_patterns=0
|
|||
Pwd=`basename %d /`
|
||||
echo -n "Name of the compressed file (without extension) [$Pwd]: "
|
||||
read tar
|
||||
if [ "$tar"x = x ]; then tar="$Pwd"; fi
|
||||
[ "$tar"x = x ] && tar="$Pwd"
|
||||
cd .. && \
|
||||
tar cf - "$Pwd" | bzip2 -f > "$tar.tar.bz2" && \
|
||||
echo "../$tar.tar.bz2 created."
|
||||
|
@ -49,7 +70,7 @@ shell_patterns=0
|
|||
Pwd=`basename %d /`
|
||||
echo -n "Name of the compressed file (without extension) [$Pwd]: "
|
||||
read tar
|
||||
if [ "$tar"x = x ]; then tar="$Pwd"; fi
|
||||
[ "$tar"x = x ] && tar="$Pwd"
|
||||
cd .. && \
|
||||
tar cf - "$Pwd" | 7za a -si "$tar.tar.7z" && \
|
||||
echo "../$tar.tar.7z created."
|
||||
|
@ -58,7 +79,7 @@ shell_patterns=0
|
|||
Pwd=`basename %d /`
|
||||
echo -n "Name of the compressed file (without extension) [$Pwd]: "
|
||||
read tar
|
||||
if [ "$tar"x = x ]; then tar="$Pwd"; fi
|
||||
[ "$tar"x = x ] && tar="$Pwd"
|
||||
cd .. && \
|
||||
tar cf - "$Pwd" | xz -f > "$tar.tar.xz" && \
|
||||
echo "../$tar.tar.xz created."
|
||||
|
@ -66,7 +87,7 @@ shell_patterns=0
|
|||
= f \.c$ & t r
|
||||
+ f \.c$ & t r & ! t t
|
||||
c Compile and link current .c file
|
||||
make `basename %f .c` 2>/dev/null || cc -O -o `basename %f .c` %f
|
||||
make "`basename %f .c`" 2>/dev/null || cc -O -o "`basename %f .c`" %f
|
||||
|
||||
+ t r & ! t t
|
||||
a Append file to opposite
|
||||
|
@ -74,59 +95,56 @@ a Append file to opposite
|
|||
|
||||
+ t t
|
||||
A Append files to opposite files
|
||||
set %t
|
||||
while [ -n "$1" ]; do
|
||||
cat "$1" >> "%D/$1"
|
||||
shift
|
||||
for i in %t ; do
|
||||
cat "$i" >> %D/"$i"
|
||||
done
|
||||
|
||||
+ t r & ! t t
|
||||
d Delete file if a copy exists in the other directory.
|
||||
if [ "%d" = "%D" ]; then
|
||||
if [ %d = %D ]; then
|
||||
echo "The two directories must be different."
|
||||
exit 1
|
||||
fi
|
||||
if [ -f %D/%f ]; then # if two of them, then
|
||||
if cmp -s %D/%f %f; then
|
||||
rm %f && echo "%f: DELETED."
|
||||
rm %f && echo %f": DELETED."
|
||||
else
|
||||
echo "%f and %D/%f differ: NOT deleted."
|
||||
echo %f" and "%D/%f" differ: NOT deleted."
|
||||
echo -n "Press RETURN "
|
||||
read key
|
||||
fi
|
||||
else
|
||||
echo "%f: No copy in %D/%f: NOT deleted."
|
||||
echo %f": No copy in "%D/%f": NOT deleted."
|
||||
fi
|
||||
|
||||
+ t t
|
||||
D Delete tagged files if a copy exists in the other directory.
|
||||
if [ "%d" = "%D" ]; then
|
||||
if [ %d = %D ]; then
|
||||
echo "The two directores must be different."
|
||||
exit 1
|
||||
fi
|
||||
for i in %t
|
||||
do
|
||||
if [ -f "%D/$i" ]; then
|
||||
SUM1="`sum \"$i\"`"
|
||||
SUM2="`sum \"%D/$i\"`"
|
||||
for i in %t ; do
|
||||
if [ -f %D/"$i" ]; then
|
||||
SUM1=`sum "$i"`
|
||||
SUM2=`sum %D/"$i"`
|
||||
if [ "$SUM1" = "$SUM2" ]; then
|
||||
rm "$i" && echo "${i}: DELETED."
|
||||
else
|
||||
echo "$i and %D/$i differ: NOT deleted."
|
||||
echo "$i and "%D"/$i differ: NOT deleted."
|
||||
fi
|
||||
else
|
||||
echo "$i has no copy in %D: NOT deleted."
|
||||
echo "$i has no copy in "%D": NOT deleted."
|
||||
fi
|
||||
done
|
||||
|
||||
m View manual page
|
||||
MAN=%{Enter manual name}
|
||||
%view{ascii,nroff} MANROFFOPT='@MAN_FLAGS@' MAN_KEEP_FORMATTING=1 man -P cat $MAN
|
||||
%view{ascii,nroff} MANROFFOPT='@MAN_FLAGS@' MAN_KEEP_FORMATTING=1 man -P cat "$MAN"
|
||||
|
||||
= f \.gz$ & t r
|
||||
+ ! t t
|
||||
n Inspect gzip'ed newsbatch file
|
||||
dd if=%f bs=1 skip=12|zcat|${PAGER-more}
|
||||
dd if=%f bs=1 skip=12 | zcat | ${PAGER-more}
|
||||
# assuming the cunbatch header is 12 bytes long.
|
||||
|
||||
= t r &
|
||||
|
@ -138,33 +156,31 @@ h Strip headers from current newsarticle
|
|||
I=`mktemp "${MC_TMPDIR:-/tmp}/news.XXXXXX"` || exit 1
|
||||
cp %f "$I" && sed '/^'"$CHECK"' /,/^$/d' "$I" > %f
|
||||
[ "$?" = "0" ] && rm "$I"
|
||||
echo "%f: header removed."
|
||||
echo %f": header removed."
|
||||
;;
|
||||
*)
|
||||
echo "%f is not a news article."
|
||||
echo %f" is not a news article."
|
||||
;;
|
||||
esac
|
||||
|
||||
+ t t
|
||||
H Strip headers from the marked newsarticles
|
||||
set %t
|
||||
while [ -n "$1" ]; do
|
||||
CHECK=`awk '{print $1 ; exit}' $1` 2>/dev/null
|
||||
for i in %t ; do
|
||||
CHECK=`awk '{print $1 ; exit}' "$i"` 2>/dev/null
|
||||
WFILE=`mktemp "${MC_TMPDIR:-/tmp}/news.XXXXXX"` || exit 1
|
||||
case "$CHECK" in
|
||||
Newsgroups:|Path:)
|
||||
cp "$1" "$WFILE" && sed '/^'"$CHECK"' /,/^$/d' "$WFILE" > "$1"
|
||||
cp "$i" "$WFILE" && sed '/^'"$CHECK"' /,/^$/d' "$WFILE" > "$i"
|
||||
if [ "$?" = "0" ]; then
|
||||
rm "$WFILE"; echo "$1 header removed. OK."
|
||||
rm "$WFILE"; echo "$i header removed. OK."
|
||||
else
|
||||
echo "Oops! Please check $1 against $WFILE."
|
||||
echo "Oops! Please check $i against $WFILE."
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "$1 skipped: Not a news article."
|
||||
echo "$i skipped: Not a news article."
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
= t r
|
||||
|
@ -174,7 +190,7 @@ r Copy file to remote host
|
|||
read Host
|
||||
echo -n "To which directory on $Host?: "
|
||||
read Dir
|
||||
rcp -p %f "${Host}:$Dir"
|
||||
rcp -p %f "${Host}:${Dir}"
|
||||
|
||||
+ t t
|
||||
R Copy files to remote host (no error checking)
|
||||
|
@ -182,25 +198,24 @@ R Copy files to remote host (no error checking)
|
|||
read Host
|
||||
echo -n "To which directory on $Host? :"
|
||||
read Dir
|
||||
rcp -pr %u "${Host}:$Dir"
|
||||
rcp -pr %u "${Host}:${Dir}"
|
||||
|
||||
= f \.tex$ & t r
|
||||
+ f \.tex$ & t r & ! t t
|
||||
t Run latex on file and show it with xdvi
|
||||
latex %f && xdvi `basename %f .tex`.dvi
|
||||
latex %f && xdvi "`basename %f .tex`".dvi
|
||||
|
||||
=+ f ^part | f ^Part | f uue & t r
|
||||
+ t t
|
||||
U Uudecode marked news articles (needs work)
|
||||
set %t
|
||||
(
|
||||
while [ -n "$1" ]; do # strip headers
|
||||
FIRST=`awk '{print $1 ; exit}' "$1"`
|
||||
cat "$1" | sed '/^'"$FIRST"' /,/^$/d'; shift
|
||||
for i in %t ; do # strip headers
|
||||
FIRST=`awk '{print $1 ; exit}' "$i"`
|
||||
cat "$i" | sed '/^'"$FIRST"' /,/^$/d'
|
||||
done
|
||||
) |sed '/^$/d' |sed -n '/^begin 6/,/^end$/p' | uudecode
|
||||
) | sed '/^$/d' | sed -n '/^begin 6/,/^end$/p' | uudecode
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "Cannot decode %t."
|
||||
echo "Cannot decode "%t"."
|
||||
fi
|
||||
echo "Please test the output file before deleting anything."
|
||||
|
||||
|
@ -208,30 +223,14 @@ U Uudecode marked news articles (needs work)
|
|||
x Extract the contents of a compressed tar file
|
||||
unset PRG
|
||||
case %f in
|
||||
*.tar.bz2)
|
||||
PRG="bunzip2 -c"
|
||||
;;
|
||||
*.tar.gz|*.tar.z|*.tgz|*.tpz|*.tar.Z)
|
||||
PRG="gzip -dc"
|
||||
;;
|
||||
*.tar.lzma)
|
||||
PRG="lzma -dc"
|
||||
;;
|
||||
*.tar.lz)
|
||||
PRG="lzip -dc"
|
||||
;;
|
||||
*.tar.lz4)
|
||||
PRG="lz4 -dc"
|
||||
;;
|
||||
*.tar.xz)
|
||||
PRG="xz -dc"
|
||||
;;
|
||||
*.tar.7z)
|
||||
PRG="7za e -so"
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
;;
|
||||
*.tar.7z) PRG="7za e -so";;
|
||||
*.tar.bz2) PRG="bunzip2 -c";;
|
||||
*.tar.gz|*.tar.z|*.tgz|*.tpz|*.tar.Z) PRG="gzip -dc";;
|
||||
*.tar.lz) PRG="lzip -dc";;
|
||||
*.tar.lz4) PRG="lz4 -dc";;
|
||||
*.tar.lzma) PRG="lzma -dc";;
|
||||
*.tar.xz) PRG="xz -dc";;
|
||||
*) exit 1;;
|
||||
esac
|
||||
$PRG %f | tar xvf -
|
||||
|
||||
|
@ -240,21 +239,18 @@ x Extract the contents of a compressed tar file
|
|||
y Gzip or gunzip current file
|
||||
unset DECOMP
|
||||
case %f in
|
||||
*.gz) DECOMP=-d;;
|
||||
*.[zZ]) DECOMP=-d;;
|
||||
*.gz|*.[zZ]) DECOMP=-d;;
|
||||
esac
|
||||
gzip $DECOMP -v %f
|
||||
gzip "$DECOMP" -v %f
|
||||
|
||||
+ t t
|
||||
Y Gzip or gunzip tagged files
|
||||
for i in %t
|
||||
do
|
||||
for i in %t ; do
|
||||
unset DECOMP
|
||||
case "$i" in
|
||||
*.gz) DECOMP=-d;;
|
||||
*.[zZ]) DECOMP=-d;;
|
||||
*.gz|*.[zZ]) DECOMP=-d;;
|
||||
esac
|
||||
gzip $DECOMP -v "$i"
|
||||
gzip "$DECOMP" -v "$i"
|
||||
done
|
||||
|
||||
+ ! t t
|
||||
|
@ -263,17 +259,16 @@ b Bzip2 or bunzip2 current file
|
|||
case %f in
|
||||
*.bz2) DECOMP=-d;;
|
||||
esac
|
||||
bzip2 $DECOMP -v %f
|
||||
bzip2 "$DECOMP" -v %f
|
||||
|
||||
+ t t
|
||||
B Bzip2 or bunzip2 tagged files
|
||||
for i in %t
|
||||
do
|
||||
for i in %t ; do
|
||||
unset DECOMP
|
||||
case "$i" in
|
||||
*.bz2) DECOMP=-d;;
|
||||
esac
|
||||
bzip2 $DECOMP -v "$i"
|
||||
bzip2 "$DECOMP" -v "$i"
|
||||
done
|
||||
|
||||
+ f \.tar.gz$ | f \.tgz$ | f \.tpz$ | f \.tar.Z$ | f \.tar.z$ | f \.tar.bz2$ | f \.tar.F$ & t r & ! t t
|
||||
|
@ -281,30 +276,29 @@ z Extract compressed tar file to subdirectory
|
|||
unset D
|
||||
set gzip -cd
|
||||
case %f in
|
||||
*.tar.gz) D="`basename %f .tar.gz`";;
|
||||
*.tgz) D="`basename %f .tgz`";;
|
||||
*.tpz) D="`basename %f .tpz`";;
|
||||
*.tar.Z) D="`basename %f .tar.Z`";;
|
||||
*.tar.z) D="`basename %f .tar.z`";;
|
||||
*.tar.bz2) D="`basename %f .tar.bz2`"; set bunzip2 -c ;;
|
||||
*.tar.F) D="`basename %f .tar.F`"; set freeze -dc;
|
||||
*.tar.F) D=`basename %f .tar.F`; set freeze -dc;;
|
||||
*.tar.Z) D=`basename %f .tar.Z`;;
|
||||
*.tar.bz2) D=`basename %f .tar.bz2`; set bunzip2 -c;;
|
||||
*.tar.gz) D=`basename %f .tar.gz`;;
|
||||
*.tar.z) D=`basename %f .tar.z`;;
|
||||
*.tgz) D=`basename %f .tgz`;;
|
||||
*.tpz) D=`basename %f .tpz`;;
|
||||
esac
|
||||
mkdir "$D"; cd "$D" && ("$1" "$2" ../%f | tar xvf -)
|
||||
|
||||
+ t t
|
||||
Z Extract compressed tar files to subdirectories
|
||||
for i in %t
|
||||
do
|
||||
for i in %t ; do
|
||||
set gzip -dc
|
||||
unset D
|
||||
case "$i" in
|
||||
*.tar.gz) D="`basename $i .tar.gz`";;
|
||||
*.tgz) D="`basename $i .tgz`";;
|
||||
*.tpz) D="`basename $i .tpz`";;
|
||||
*.tar.Z) D="`basename $i .tar.Z`";;
|
||||
*.tar.z) D="`basename $i .tar.z`";;
|
||||
*.tar.F) D="`basename $i .tar.F`"; set freeze -dc;;
|
||||
*.tar.bz2) D="`basename $i .tar.bz2`"; set bunzip2 -c;;
|
||||
*.tar.F) D=`basename "$i" .tar.F`; set freeze -dc;;
|
||||
*.tar.Z) D=`basename "$i" .tar.Z`;;
|
||||
*.tar.bz2) D=`basename "$i" .tar.bz2`; set bunzip2 -c;;
|
||||
*.tar.gz) D=`basename "$i" .tar.gz`;;
|
||||
*.tar.z) D=`basename "$i" .tar.z`;;
|
||||
*.tgz) D=`basename "$i" .tgz`;;
|
||||
*.tpz) D=`basename "$i" .tpz`;;
|
||||
esac
|
||||
mkdir "$D"; (cd "$D" && "$1" "$2" "../$i" | tar xvf -)
|
||||
done
|
||||
|
@ -314,53 +308,49 @@ c Convert gz<->bz2, tar.gz<->tar.bz2 & tgz->tar.bz2
|
|||
unset D
|
||||
unset EXT
|
||||
case %f in
|
||||
*.Z) EXT=Z;;
|
||||
*.bz2) EXT=bz2;;
|
||||
*.gz) EXT=gz;;
|
||||
*.tgz) EXT=tgz;;
|
||||
*.tpz) EXT=tpz;;
|
||||
*.Z) EXT=Z;;
|
||||
*.z) EXT=z;;
|
||||
*.gz) EXT=gz;;
|
||||
*.bz2) EXT=bz2;;
|
||||
esac
|
||||
case $EXT in
|
||||
tgz|tpz) D="`basename %f .$EXT`.tar";;
|
||||
gz|Z|z) D="`basename %f .$EXT`";;
|
||||
bz2) D="`basename %f .bz2`";;
|
||||
case "$EXT" in
|
||||
bz2|Z|gz|z) D=`basename %f ."$EXT"`;;
|
||||
tgz|tpz) D=`basename %f ."$EXT"`.tar;;
|
||||
esac
|
||||
if [ "$EXT" = "bz2" ]; then
|
||||
bunzip2 -v %f ; gzip -f9 -v "$D"
|
||||
bunzip2 -v %f
|
||||
gzip -f9 -v "$D"
|
||||
else
|
||||
gunzip -v %f ; bzip2 -v "$D"
|
||||
gunzip -v %f
|
||||
bzip2 -v "$D"
|
||||
fi
|
||||
|
||||
+ t t
|
||||
C Convert gz<->bz2, tar.gz<->tar.bz2 & tgz->tar.bz2
|
||||
set %t
|
||||
while [ -n "$1" ]
|
||||
do
|
||||
for i in %t ; do
|
||||
unset D
|
||||
unset EXT
|
||||
case "$1" in
|
||||
case "$i" in
|
||||
*.Z) EXT=Z;;
|
||||
*.bz2) EXT=bz2;;
|
||||
*.gz) EXT=gz;;
|
||||
*.tgz) EXT=tgz;;
|
||||
*.tpz) EXT=tpz;;
|
||||
*.Z) EXT=Z;;
|
||||
*.z) EXT=z;;
|
||||
*.gz) EXT=gz;;
|
||||
*.bz2) EXT=bz2;;
|
||||
esac
|
||||
case $EXT in
|
||||
tgz) D="`basename $1 .tgz`.tar";;
|
||||
tpz) D="`basename $1 .tpz`.tar";;
|
||||
gz|Z|z) D="`basename $1 .$EXT`";;
|
||||
bz2) D="`basename $1 .bz2`";;
|
||||
case "$EXT" in
|
||||
bz2|Z|gz|z) D=`basename "$i" ."$EXT"`;;
|
||||
tgz|tpz) D=`basename "$i" ."$EXT"`.tar;;
|
||||
esac
|
||||
if [ "$EXT" = "bz2" ]; then
|
||||
bunzip2 -v "$1"
|
||||
bunzip2 -v "$i"
|
||||
gzip -f9 -v "$D"
|
||||
else
|
||||
gunzip -v "$1"
|
||||
gunzip -v "$i"
|
||||
bzip2 -v "$D"
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
+ x /usr/bin/open | x /usr/local/bin/open & x /bin/sh
|
||||
|
|
Loading…
Reference in New Issue