quilt-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Quilt-dev] [PATCH] inspect: Handle long options passed to tar


From: Jean Delvare
Subject: [Quilt-dev] [PATCH] inspect: Handle long options passed to tar
Date: Thu, 31 Jul 2014 18:16:10 +0200

The command line interface to tar is complex and sometimes confusing,
but we should still do our best to figure where the file name is on
that command line.

Add support for the --file FILE and --file=FILE options. Other long
options must be explicitly skipped, as well as short options not
containing the letter "f".

With this we should be good to go in most real-world cases, but
there are still a few corner cases we may not handle properly. These
can be addressed later when reported.
---
 quilt/scripts/inspect.in |   34 ++++++++++++++++++++++++++--------
 1 file changed, 26 insertions(+), 8 deletions(-)

--- a/quilt/scripts/inspect.in
+++ b/quilt/scripts/inspect.in
@@ -249,14 +249,32 @@ cat <<-'EOF' > $tmpdir/bin/wrapper
 
        tar_input_file()
        {
-               case "$1" in
-               *C*f*)
-                       echo "$3"
-                       ;;
-               *f*)
-                       echo "$2"
-                       ;;
-               esac
+               while [ $# -gt 0 ]; do
+                       case "$1" in
+                       --file)
+                               echo "$2"
+                               return
+                               ;;
+                       --file=*)
+                               echo "${1#--file=}"
+                               return
+                               ;;
+                       --*)
+                               shift
+                               ;;
+                       *C*f*)
+                               echo "$3"
+                               return
+                               ;;
+                       *f*)
+                               echo "$2"
+                               return
+                               ;;
+                       -*)
+                               shift
+                               ;;
+                       esac
+               done
        }
 
        unzip_input_file()

-- 
Jean Delvare
SUSE L3 Support




reply via email to

[Prev in Thread] Current Thread [Next in Thread]