Re: Problem using -E option with paths containing spaces

Per Jensen <[email protected]>
Newsgroups gmane.comp.sysutils.backup.dar.support
Message-ID <[email protected]>
Hi Denis, again.

Your email put me on the right path, I added "\'" around the paths 
provided to the -E option in a configuration file.

create:
   -E '\'@@CONFDIR@@/dar_par_create.duc\' "%p" "%b" "%N" "%e" "%c" 5'

That did the trick :-)

Thank you for helping me out.

Cheers
Per


Den 12.04.2022 kl. 07.58 skrev Per Jensen:
> Hi Denis,
> 
> Many thanks for you very thorough answer, much appreciated. I will 
> dabble more with different kinds of quoting to get it working :-)
> 
> Best regards
> Per
> 
> Den 11.04.2022 kl. 22.50 skrev Denis Corbin:
>> Le 11/04/2022 à 15:43, Per Jensen a écrit :
>>> All,
>>
>> Hi Per,
>>
>>>
>>> I have an issue making dar (I think) run a par2 script when the path to
>>> the par2 script has spaces in directory names.
>>
>> I tried this simple test:
>>
>> cd /tmp
>> mkdir "With Space"
>> cp /bin/ls With\ Space
>> dar -c test -s 1M -E '/tmp/With\ Space/ls %p/%b.%N.%e' -N
>> Warning: using insecure memory!
>> /tmp/test.1.dar
>> /tmp/test.2.dar
>> /tmp/test.3.dar
>> /tmp/test.4.dar
>> /tmp/test.5.dar
>> /tmp/test.6.dar
>> /tmp/test.7.dar
>> /tmp/test.8.dar
>> [...]
>>
>> so to my point of view, there does not seem to be any problem when the
>> path given to -E option contains space.
>>
>> [...]
>>
>>> This works (using escaped spaces in path to the -E option):
>>> ==========================================
>>> ➜ ~/.local/bin/dar_static_2.7.4 -Q -c '/tmp/TEST_FULL_2022-04-11' -N -B
>>> '/tmp/  abc/   def/dar-backup-test/bin/../backups.d/TEST' -E '/tmp/\ \
>>> abc/\ \ \ def/dar-backup-test/bin/../conf/dar_par_create.duc "%p" "%b"
>>> "%N" "%e" "%c" 5'
>>> PAR2 started: "/tmp/  abc/
>>> def/dar-backup-test/bin/../conf/dar_par_create.duc"
>>> creating PAR file for file /tmp/TEST_FULL_2022-04-11.1.dar ...
>>
>>
>> You have to take into account that the command you type on the shell
>> prompt is first interpreted before being passed to dar. Then the
>> argument given to -E option is passed to a second shell for execution:
>>
>> The shell job is to split the long string you type at the prompt, into
>> words. Words are separated by spaces unless spaces are escaped or when
>> spaces are quoted (simple quote (') double quoted (") back quote (`) all
>> having a different meaning for most shells but still avoid space to be
>> considered as word separator).
>>
>> So when you type at the shell prompt the following string
>>     dar -E "Hello world"
>> the shell CLI parser will provide three words, which I put between
>> brackets for clarity:
>>     [dar] [-E] [Hello world]
>>
>> Note that the double quotes (") have been removed by the shell.
>> dar is then executed with two arguments [-E] and [Hello world] given by
>> the shell.
>>
>> dar's work is then to pass the word following "-E" to a new shell
>> process. This second shell will read the string [Hello wolrd] as if you
>> have typed it at the prompt and will also split it into words, leading
>> to this list of words:
>>     [Hello] [world]
>>
>> If the command you want dar to run is not "Hello" but "Hello world" you
>> have to quote/escape twice the spaces, once for the shell you use to run
>> dar from, and a second time for the shell that dar runs to interpret the
>> argument given to -E option.
>>
>> in my example I can use the following instead of escaping the space(s):
>>
>> dar -c test -s 1M -E '"/tmp/With Space/ls" %p/%b.%N.%e' -N
>>
>> [...]
>>
>> Cheers,
>> Denis
>>
>>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.