[Top][All Lists]

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

Re: Quotes in Dired listing switches

From: Juri Linkov
Subject: Re: Quotes in Dired listing switches
Date: Mon, 11 Jan 2010 02:43:35 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.91 (x86_64-pc-linux-gnu)

>>   (setq dired-listing-switches "-al --block-size=\"'1\"")
> [...]
>> (apply 'call-process
>>        insert-directory-program nil t nil
>>        '("--dired" "-al" "--block-size=\"'1\"" "--" "/tmp/."))
> [...]
>> then Dired works correctly, but with e.g. `C-x d /sudo::/tmp'
>> Tramp hangs because the unmatched single quote causes the shell
>> to wait for the closing quote.
> Obviously, there's a problem in the inconsistent parsing of
> dired-listing-switches, where the basic code splits it at spaces without
> doing any additional unquoting or analysis, whereas the Tramp code seems
> to just pass it as-is to the shell (so if you set it to "-al $(rm -rf ~/.)"
> it will try to do something funny).
> I won't claim that the basic code's naive splitting is great, but
> Tramp's similarly naive use is not great either.  So, I suggest to treat
> it as a bug in Tramp which should split it like the basic code and then
> shell-quote-argument the parts.

There is still something wrong in `insert-directory'.  Currently it's
impossible to use both `C-x d dir-name RET' and `C-x d file-name RET'
(where the latter specifies a filename wildcard for dired).

With (setq dired-listing-switches "-al --block-size='1")
`insert-directory' succeeds for `C-x d /tmp/ RET', but fails
for `C-x d /tmp/file RET'.

With (setq dired-listing-switches "-al --block-size=\"'1\"")
`insert-directory' fails for `C-x d /tmp/ RET', and succeeds
for `C-x d /tmp/file RET'.

The difference in `insert-directory' is in the `if wildcard' condition:
the first branch calls `insert-directory-program' using `shell-file-name',
the second branch calls `insert-directory-program' directly.

Juri Linkov

reply via email to

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