zsh-workers
 help / color / mirror / code / Atom feed
* Coreutils-like File Completion
@ 2017-10-05  0:24 Noam Barnea
  2017-10-05  0:34 ` Eric Cook
  0 siblings, 1 reply; 6+ messages in thread
From: Noam Barnea @ 2017-10-05  0:24 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 422 bytes --]

Since coreutils-8.24 (as far as I can tell from the Coreutils git), ls
escaped filenames with single quotes instead of backslashes. On zsh (zsh
5.4.2 stable, freshly installed) escaped filenames in filename completion
(typing cd then pressing Tab) are still escaped with backslashes. I think
the Coreutils standard should be followed as it is more shell-friendly and
promotes better, more efficient commandline practices.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Coreutils-like File Completion
  2017-10-05  0:24 Coreutils-like File Completion Noam Barnea
@ 2017-10-05  0:34 ` Eric Cook
  2017-10-05 13:37   ` Leah Neukirchen
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Cook @ 2017-10-05  0:34 UTC (permalink / raw)
  To: zsh-workers

On 10/04/2017 08:24 PM, Noam Barnea wrote:
> Since coreutils-8.24 (as far as I can tell from the Coreutils git), ls
> escaped filenames with single quotes instead of backslashes. On zsh (zsh
> 5.4.2 stable, freshly installed) escaped filenames in filename completion
> (typing cd then pressing Tab) are still escaped with backslashes. I think
> the Coreutils standard should be followed as it is more shell-friendly and
> promotes better, more efficient commandline practices.
> 

Quoting, what i am assuming that you are referring to, spaces, with single quotes
or backslashes results in the space not being treated syntactically in all
bourne-like shells. one isn't more "shell-friendly" than the other.

On another note, if you type an ' before pressing tab, zsh will still complete the filename
and add the closing ' if an file is selected, the closing ' won't be added if the selected item
is an directory (since you may attempt to do further completion).


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Coreutils-like File Completion
  2017-10-05  0:34 ` Eric Cook
@ 2017-10-05 13:37   ` Leah Neukirchen
  2017-10-05 19:56     ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Leah Neukirchen @ 2017-10-05 13:37 UTC (permalink / raw)
  To: zsh-workers

Eric Cook <llua@gmx.com> writes:

> On 10/04/2017 08:24 PM, Noam Barnea wrote:
>> Since coreutils-8.24 (as far as I can tell from the Coreutils git), ls
>> escaped filenames with single quotes instead of backslashes. On zsh (zsh
>> 5.4.2 stable, freshly installed) escaped filenames in filename completion
>> (typing cd then pressing Tab) are still escaped with backslashes. I think
>> the Coreutils standard should be followed as it is more shell-friendly and
>> promotes better, more efficient commandline practices.
>> 
>
> Quoting, what i am assuming that you are referring to, spaces, with single quotes
> or backslashes results in the space not being treated syntactically in all
> bourne-like shells. one isn't more "shell-friendly" than the other.
>
> On another note, if you type an ' before pressing tab, zsh will still
> complete the filename
> and add the closing ' if an file is selected, the closing ' won't be
> added if the selected item
> is an directory (since you may attempt to do further completion).

This only seems to happen without compinit, anyone know how to revert
to this behavior and still use compinit?
(With compinit, ' is removed on TAB and the completion uses \ here...)

-- 
Leah Neukirchen  <leah@vuxu.org>  http://leah.zone


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Coreutils-like File Completion
  2017-10-05 13:37   ` Leah Neukirchen
@ 2017-10-05 19:56     ` Bart Schaefer
  2017-10-06 11:28       ` Leah Neukirchen
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2017-10-05 19:56 UTC (permalink / raw)
  To: zsh-workers, zsh-workers

On Oct 5,  3:37pm, Leah Neukirchen wrote:
} Subject: Re: Coreutils-like File Completion
}
} Eric Cook <llua@gmx.com> writes:
} 
} > On another note, if you type an ' before pressing tab, zsh will
} > still complete the filename and add the closing ' if an file is
} > selected, the closing ' won't be added if the selected item is an
} > directory (since you may attempt to do further completion).
} 
} This only seems to happen without compinit, anyone know how to revert
} to this behavior and still use compinit?
} (With compinit, ' is removed on TAB and the completion uses \ here...)

Hmm, I don't see your behavior.  I have a directory full of deliberately
strangely-named files just for testing stuff like this.

torch% ls *' '*         
two three  with spaces

a (test):
bar  foo

dir two:
dir3  file two
torch% print 'w<TAB>
torch% print 'with spaces' <C-U>
torch% echo 'a<TAB>
a'\''b      abc         answerfile  a (test)/

Notice how, in the file name that contains a single quote, the listing
has closed the quote after the first "a", then backslashed the embedded
single quote, and then opened the quotes again before "b".  If I cycle
the matches by repeately pressing TAB:

torch% echo 'a<TAB>
torch% echo 'a'\''b<TAB>
torch% echo 'abc'<TAB>
torch% echo 'answerfile'<TAB>
torch% echo 'a (test)/

And so on.  This is all with compinit having run.

You should make sure that you're not confusing completion with expansion,
and for zstyles or setopts that may be making a difference.

There is a bit of a glitch above -- "a'b" is a directory, but the trailing
"/" is not being appended, and completion into that directory doesn't
work; the multiple quotings have confused path completion.  It works if I
allow completion to supply the quoting:

torch% echo a<TAB><TAB>
torch% echo a\'b/

It also works if I start from a double quote so that it's not necessary
to close and reopen the single quotes:

torch% echo "a<TAB><TAB>
torch% echo "a'b/

Figuring out what the user means in order to unwind it, do a path search,
and then put it all back again, is of necessity heuristic, and doesn't
always work.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Coreutils-like File Completion
  2017-10-05 19:56     ` Bart Schaefer
@ 2017-10-06 11:28       ` Leah Neukirchen
  2017-10-06 16:21         ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Leah Neukirchen @ 2017-10-06 11:28 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

Bart Schaefer <schaefer@brasslantern.com> writes:

> On Oct 5,  3:37pm, Leah Neukirchen wrote:
> } Subject: Re: Coreutils-like File Completion
> }
> } Eric Cook <llua@gmx.com> writes:
> } 
> } > On another note, if you type an ' before pressing tab, zsh will
> } > still complete the filename and add the closing ' if an file is
> } > selected, the closing ' won't be added if the selected item is an
> } > directory (since you may attempt to do further completion).
> } 
> } This only seems to happen without compinit, anyone know how to revert
> } to this behavior and still use compinit?
> } (With compinit, ' is removed on TAB and the completion uses \ here...)
>
> Hmm, I don't see your behavior.  I have a directory full of deliberately
> strangely-named files just for testing stuff like this.

Oh, my bad.

I tried /tmp/'foo<TAB> not '/tmp/foo<TAB>.
With an initial ' or " it works fine, sorry for the confusion.

-- 
Leah Neukirchen  <leah@vuxu.org>  http://leah.zone


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Coreutils-like File Completion
  2017-10-06 11:28       ` Leah Neukirchen
@ 2017-10-06 16:21         ` Bart Schaefer
  0 siblings, 0 replies; 6+ messages in thread
From: Bart Schaefer @ 2017-10-06 16:21 UTC (permalink / raw)
  To: zsh-workers

On Fri, Oct 6, 2017 at 4:28 AM, Leah Neukirchen <leah@vuxu.org> wrote:
> Bart Schaefer <schaefer@brasslantern.com> writes:
>
> Oh, my bad.
>
> I tried /tmp/'foo<TAB> not '/tmp/foo<TAB>.
> With an initial ' or " it works fine, sorry for the confusion.


You might take a look at Functions/Zle/quote-and-complete-word which
is included in the zsh distribution.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-10-06 16:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-05  0:24 Coreutils-like File Completion Noam Barnea
2017-10-05  0:34 ` Eric Cook
2017-10-05 13:37   ` Leah Neukirchen
2017-10-05 19:56     ` Bart Schaefer
2017-10-06 11:28       ` Leah Neukirchen
2017-10-06 16:21         ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).