bug-tar
[Top][All Lists]
Advanced

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

[Bug-tar] --files-from and files with spaces


From: Vladimir A . Pavlov
Subject: [Bug-tar] --files-from and files with spaces
Date: Mon, 03 Aug 2015 01:24:07 +0300

Hello.

The script at the end demonstrates how difficult it is sometimes to use gnu
tar --files-from in automated scripts.

If I have a file "-b b" in tar, the only way to include it via --files-from is 
by line:
--add-file="-b b"
(case E in the script below)

So if the list is generated automatically the generating program has to care
about files starting with dashes, files including spaces, files with double
quotes and probably others.

Is it the expected behaviour?

It would be much easier if one could force tar to consider the whole line as 
file
name. If \n is chosen as the separator then it would be great if no spaces are
considered as separators so the following lines would be fine:
--add-file
-b b
(case C in the script below)

Are there plans to fix the issue?

""" SCRIPT BEGIN """
#!/bin/sh

mkdir /tmp/dir
cd /tmp/dir
touch -- "-b b"
tar -cf ../dir.tar -- .
cd ..
rm -rf dir

printf "%s\n" "A:"
tar -tf dir.tar
echo

printf "%s\n" "B:-b b"
printf "%s\n" "-b b" >dir.list
tar -tf dir.tar -T dir.list
echo

printf "%s\n" "C:--add-file" "C:./-b b"
printf "%s\n" "--add-file" "./-b b" >dir.list
tar -tf dir.tar -T dir.list
echo

printf "%s\n" "D:--add-file=./-b b"
printf "%s\n" "--add-file=./-b b" >dir.list
tar -tf dir.tar -T dir.list
echo

printf "%s\n" "E:--add-file=\"./-b b\""
printf "%s\n" "--add-file=\"./-b b\"" >dir.list
tar -tf dir.tar -T dir.list
echo
""" SCRIPT END """

-- 
Vladimir A. Pavlov

reply via email to

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