Package: p7zip
Severity: normal
Tags: patch

A few improvements to p7zip wrapper:

- Fail when passed unknown options!
- Use exec when possible to avoid a fork.
- Fix tty detection.

-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.17-1-amd64-k8
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL 
set to en_US.UTF-8)
diff -ur p7zip-4.42.dfsg.1.old/debian/scripts/p7zip 
p7zip-4.42.dfsg.1/debian/scripts/p7zip
--- p7zip-4.42.dfsg.1.old/debian/scripts/p7zip  2006-07-23 12:06:13.000000000 
+0200
+++ p7zip-4.42.dfsg.1/debian/scripts/p7zip      2006-07-23 12:08:39.000000000 
+0200
@@ -19,7 +19,7 @@
   case "$1" in
     -d) compress=false ;; # decompressing
     -c) echo "$0: ignoring $1 option (not yet implemented)" ;;
-    -h|--help) usage ;;
+    -h|--help|-*) usage ;;
     *)
       if [ "${file}" = "" ] ; then
         file="$1"
@@ -42,26 +42,26 @@
 if [ "${file}" != "" ] ; then
   if ${compress} ; then
     7zr a "${file}.7z" "${file}"
-    rm "${file}"
+    exec rm "${file}"
   else
     case "${file}" in
       *.7z)
         7zr x "${file}"
-        rm "${file}"
+        exec rm "${file}"
       ;;
       *)
         echo "$0: ${file}: unknown suffix -- ignored"
+        exit 0
       ;;
     esac
   fi
-  exit 0
 fi
 
 tmp=`mktemp`
 trap "rm -f ${tmp}" 0
 
 if ${compress} ; then
-  if tty > /dev/null ; then
+  if tty -s <&1 >/dev/null ; then
     echo "$0: compressed data not written to a terminal."
     echo "For help, type: $0 -h"
     exit 1
@@ -74,4 +74,4 @@
   7zr x ${tmp} -so 2>/dev/null | cat
 fi
 
-rm -f ${tmp}
+exec rm -f ${tmp}

Reply via email to