zsh-workers
 help / color / mirror / code / Atom feed
* _sh doing _normal completion
@ 2018-03-27 13:34 Leah Neukirchen
  2018-03-27 19:33 ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Leah Neukirchen @ 2018-03-27 13:34 UTC (permalink / raw)
  To: zsh-workers

Hi,

the default _sh completion tries _files, then falls back to _normal.
However, sh, [t]csh and rc don't support this, and ksh/bash only
support it for actual shell scripts.

So I wonder if this is a reasonable completion?

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


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

* Re: _sh doing _normal completion
  2018-03-27 13:34 _sh doing _normal completion Leah Neukirchen
@ 2018-03-27 19:33 ` Peter Stephenson
  2018-03-28 13:46   ` Leah Neukirchen
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Stephenson @ 2018-03-27 19:33 UTC (permalink / raw)
  To: zsh-workers

On Tue, 27 Mar 2018 15:34:12 +0200
Leah Neukirchen <leah@vuxu.org> wrote:
> the default _sh completion tries _files, then falls back to _normal.
> However, sh, [t]csh and rc don't support this, and ksh/bash only
> support it for actual shell scripts.
> 
> So I wonder if this is a reasonable completion?

Do you mean falling back to _normal isn't sensible, i.e. it's not worth
assuming you can specify an executable command or similar after the file
name, since it's unlikely the shell can handle it? It's not a particularly
sophisticated fallback, certainly.  It's possible you could think of a
better way of searching for finding a script in the path, which I guess
is the real intention.  Until someone does, this is probably going to
stay the best we've got.

pws


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

* Re: _sh doing _normal completion
  2018-03-27 19:33 ` Peter Stephenson
@ 2018-03-28 13:46   ` Leah Neukirchen
  2018-03-28 13:59     ` Stephane Chazelas
  0 siblings, 1 reply; 4+ messages in thread
From: Leah Neukirchen @ 2018-03-28 13:46 UTC (permalink / raw)
  To: zsh-workers

Peter Stephenson <p.w.stephenson@ntlworld.com> writes:

> On Tue, 27 Mar 2018 15:34:12 +0200
> Leah Neukirchen <leah@vuxu.org> wrote:
>> the default _sh completion tries _files, then falls back to _normal.
>> However, sh, [t]csh and rc don't support this, and ksh/bash only
>> support it for actual shell scripts.
>> 
>> So I wonder if this is a reasonable completion?
>
> Do you mean falling back to _normal isn't sensible, i.e. it's not worth
> assuming you can specify an executable command or similar after the file
> name, since it's unlikely the shell can handle it? It's not a particularly
> sophisticated fallback, certainly.  It's possible you could think of a
> better way of searching for finding a script in the path, which I guess
> is the real intention.  Until someone does, this is probably going to
> stay the best we've got.

The main problem is that it floods the reasonable expansions (from .)
with the full contents of $PATH.

As discussed in #zsh I now use:
zstyle ':completion:*:(sh|rc):*' tag-order '! commands builtins'

(POSIX /bin/sh may do a PATH lookup, but dash and OpenBSD sh don't.)

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


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

* Re: _sh doing _normal completion
  2018-03-28 13:46   ` Leah Neukirchen
@ 2018-03-28 13:59     ` Stephane Chazelas
  0 siblings, 0 replies; 4+ messages in thread
From: Stephane Chazelas @ 2018-03-28 13:59 UTC (permalink / raw)
  To: Leah Neukirchen; +Cc: zsh-workers

2018-03-28 15:46:32 +0200, Leah Neukirchen:
[...]
> The main problem is that it floods the reasonable expansions (from .)
> with the full contents of $PATH.
[...]

Some sh implementations (bash, zsh, AT&T ksh) look-up slash-less
commands in $PATH if not found in the currently directory, some
(mksh, dash, yash) don't. Both behaviours are allowed by POSIX.

ksh88 actually looked it up in $PATH *before* the current
directory, causing security vulnerabilities on systems with
support for setuid scripts for instance.

If you want to run a script in the current directory, I would
suggest you get  used to typing:

sh ./myscr<Tab>

to avoid surprises on those systems that lookup scripts in
$PATH. The fact that zsh completes commands in $PATH when you do
sh myscr<Tab> is actually useful as a reminder that it's not a
wise thing to do.

-- 
Stephane


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

end of thread, other threads:[~2018-03-28 13:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-27 13:34 _sh doing _normal completion Leah Neukirchen
2018-03-27 19:33 ` Peter Stephenson
2018-03-28 13:46   ` Leah Neukirchen
2018-03-28 13:59     ` Stephane Chazelas

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).