From 1e9f433f693b4ee09ebf3267222b11694448e81f Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Mon, 13 Oct 2014 14:38:26 +0200 Subject: 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. --- quilt/scripts/inspect.in | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) 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() -- cgit