[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-tar] file name with backslash is not archived
From: |
Hugo Mildenberger |
Subject: |
Re: [Bug-tar] file name with backslash is not archived |
Date: |
Tue, 2 Nov 2010 13:05:47 +0100 |
User-agent: |
KMail/1.13.5 (Linux/2.6.35.7-grsec; KDE/4.5.2; x86_64; ; ) |
On Tuesday 02 November 2010 08:38:34 Paul Eggert wrote:
> Ah, thanks, that explains things. But the problem was not
> within tar: it was that tar was being given the wrong
> command-line argument.
No Paul, the bug really occures when tar unquotes a string passed
from command line. I changed your test program a bit to accept
a file name from command line ...
#include <stdio.h>
#include <sys/stat.h>
int
main (int argc, char **argv)
{
const char *file_name = (argc > 1 )
? *++argv
: "Please provide a filename";
struct stat st;
int status = lstat (file_name, &st);
fprintf(stderr,"lstat('%s'): status was %d = %m\n",file_name,status);
return status ? 1 : 0;
}
... and compiled it to a program named "test2".
$ touch 'hello world\n'
$ ls -l hello\ world\\n
-rw-r--r-- 1 hm hm 0 Nov 2 11:31 hello world\n
$ ./test2 hello\ world\\n
lstat('hello world\n'): status was 0 = Success
$ ./test2 "hello world\\n"
lstat('hello world\n'): status was 0 = Success
$ ./test2 'hello world\n'
lstat('hello world\n'): status was 0 = Success
$ ./test2 "hello world\n"
lstat('hello world\n'): status was 0 = Success
$ ./test2 'hello world\\n'
lstat('hello world\\n'): status was -1 = No such file or directory
Now running the same tests with tar:
$ tar --version
tar (GNU tar) 1.24
$ tar -cf x.tar hello\ world\\n
tar: hello world\n: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
$ tar -cf x.tar "hello world\\n"
tar: hello world\n: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
$ tar -cf x.tar 'hello world\n'
tar: hello world\n: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
$ tar -cf x.tar "hello world\n"
tar: hello world\n: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
$ tar -cf x.tar 'hello world\\n'
(Success)
- Re: [Bug-tar] file name with backslash is not archived, Paul Eggert, 2010/11/01
- Re: [Bug-tar] file name with backslash is not archived, Динар, 2010/11/01
- Re: [Bug-tar] file name with backslash is not archived, Paul Eggert, 2010/11/02
- Re: [Bug-tar] file name with backslash is not archived,
Hugo Mildenberger <=
- Re: [Bug-tar] file name with backslash is not archived, Sergey Poznyakoff, 2010/11/02
- Re: [Bug-tar] file name with backslash is not archived, Hugo Mildenberger, 2010/11/02
- Re: [Bug-tar] file name with backslash is not archived, Sergey Poznyakoff, 2010/11/02
- Re: [Bug-tar] file name with backslash is not archived, Hugo Mildenberger, 2010/11/02
- Re: [Bug-tar] file name with backslash is not archived, Sergey Poznyakoff, 2010/11/02
- Re: [Bug-tar] file name with backslash is not archived, Joerg Schilling, 2010/11/03
- Re: [Bug-tar] file name with backslash is not archived, Joerg Schilling, 2010/11/03
- Re: [Bug-tar] file name with backslash is not archived, Paul Eggert, 2010/11/02
- Re: [Bug-tar] file name with backslash is not archived, Eric Blake, 2010/11/02
- Re: [Bug-tar] file name with backslash is not archived, Paul Eggert, 2010/11/02