diff options
author | Jean Delvare <jdelvare@suse.de> | 2014-10-13 14:38:26 +0200 |
---|---|---|
committer | Jean Delvare <jdelvare@suse.de> | 2014-10-13 14:38:26 +0200 |
commit | 1e9f433f693b4ee09ebf3267222b11694448e81f (patch) | |
tree | a5edcc5a51cacf8b77c08767562b2905bd4b5b55 | |
parent | c7b479354c4fbcc36e567420aada536cb810d6cf (diff) | |
download | quilt-1e9f433f693b4ee09ebf3267222b11694448e81f.tar.gz |
inspect: Handle long options passed to tar
The command line interface to tar is complex and sometimes confusing,
but we should still do our best to figure out 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. Let's
just hope we never hit them.
Reported by Petr Tesarik.
-rw-r--r-- | quilt/scripts/inspect.in | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/quilt/scripts/inspect.in b/quilt/scripts/inspect.in index bf8221e..f38004b 100644 --- a/quilt/scripts/inspect.in +++ b/quilt/scripts/inspect.in @@ -250,13 +250,58 @@ cat <<-'EOF' > $tmpdir/bin/wrapper tar_input_file() { case "$1" in + # Modern option format + -*) + while [ $# -gt 0 ]; do + case "$1" in + # Extract the file name (long option) + --file) + echo "$2" + return + ;; + --file=*) + echo "${1#--file=}" + return + ;; + # Skip other long options + --*) + shift + ;; + # Extract the file name (short option) + -*f) + echo "$2" + return + ;; + -f*) + echo "${1#-f}" + return + ;; + # Skip other short options and parameters + *) + shift + ;; + esac + done + ;; + # Legacy option format (must always come first) *C*f*) echo "$3" + return ;; *f*) echo "$2" + return + ;; + ?*) + # Eat legacy options and try again + until [ $# -eq 0 -o "${1:0:1}" = "-" ]; do + shift + done + tar_input_file "$@" + return ;; esac + return 1 } unzip_input_file() |