zsh-users
 help / color / mirror / code / Atom feed
* unexpected wildcard issue
@ 2007-03-08  4:51 Atom Smasher
  2007-03-08  4:54 ` Dan Nelson
  0 siblings, 1 reply; 4+ messages in thread
From: Atom Smasher @ 2007-03-08  4:51 UTC (permalink / raw)
  To: zsh-users

### create some "xyz" file
$ touch {1..10}.xyz

### check that they're there, using a wildcard
$ ls  *xyz
0.xyz	1.xyz	10.xyz	2.xyz	3.xyz	4.xyz	5.xyz	6.xyz	7.xyz 
8.xyz	9.xyz

### create another file with a leading dash in the filename
$ touch ./-11.xyz

### check again, with a wildcard
$ ls  *xyz
ls: illegal option -- .
usage: ls [-ABCFGHILPRSTWZabcdfghiklmnopqrstuwx1] [file ...]

:::::::::::

should the shell protect expanded file names, as if they were entered in 
quotes?


-- 
         ...atom

  ________________________
  http://atom.smasher.org/
  762A 3B98 A3C3 96C9 C6B7 582A B88D 52E4 D9F5 7808
  -------------------------------------------------

 	"It has become appallingly obvious that our
 	 technology has exceeded our humanity."
 		-- Albert Einstein



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

* Re: unexpected wildcard issue
  2007-03-08  4:51 unexpected wildcard issue Atom Smasher
@ 2007-03-08  4:54 ` Dan Nelson
  2007-03-08  5:12   ` Atom Smasher
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Nelson @ 2007-03-08  4:54 UTC (permalink / raw)
  To: Atom Smasher; +Cc: zsh-users

In the last episode (Mar 07), Atom Smasher said:
> ### create some "xyz" file
> $ touch {1..10}.xyz
> 
> ### check that they're there, using a wildcard
> $ ls  *xyz
> 0.xyz	1.xyz	10.xyz	2.xyz	3.xyz	4.xyz	5.xyz	6.xyz	7.xyz
> 8.xyz 9.xyz
> 
> ### create another file with a leading dash in the filename
> $ touch ./-11.xyz
> 
> ### check again, with a wildcard
> $ ls  *xyz
> ls: illegal option -- .
> usage: ls [-ABCFGHILPRSTWZabcdfghiklmnopqrstuwx1] [file ...]
> 
> :::::::::::
> 
> should the shell protect expanded file names, as if they were entered
> in quotes?

Doesn't matter.  Even if quoted, ls would still see as its first
argument something starting with a dash, which it will interpret as an
option.  Use "ls -- *xyz" or "ls ./*xyz" to ensure that none of the
expanded filenames get mistaken for options.

-- 
	Dan Nelson
	dnelson@allantgroup.com


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

* Re: unexpected wildcard issue
  2007-03-08  4:54 ` Dan Nelson
@ 2007-03-08  5:12   ` Atom Smasher
  2007-03-08 17:47     ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Atom Smasher @ 2007-03-08  5:12 UTC (permalink / raw)
  To: zsh-users

On Wed, 7 Mar 2007, Dan Nelson wrote:

> Doesn't matter.  Even if quoted, ls would still see as its first 
> argument something starting with a dash, which it will interpret as an 
> option.  Use "ls -- *xyz" or "ls ./*xyz" to ensure that none of the 
> expanded filenames get mistaken for options.
==================

ok... so, should the shell insert an implied "--" before expanding 
wildcards or globs? is there an option for that? should there be?

thanks...


-- 
         ...atom

  ________________________
  http://atom.smasher.org/
  762A 3B98 A3C3 96C9 C6B7 582A B88D 52E4 D9F5 7808
  -------------------------------------------------

 	"When one tries to rise above Nature one is
 	 liable to fall below it."
 		-- Sherlock Holmes (Arthur Conan Doyle)



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

* Re: unexpected wildcard issue
  2007-03-08  5:12   ` Atom Smasher
@ 2007-03-08 17:47     ` Bart Schaefer
  0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2007-03-08 17:47 UTC (permalink / raw)
  To: Atom Smasher, zsh-users

On Mar 8, 12:12am, Atom Smasher wrote:
}
} ok... so, should the shell insert an implied "--" before expanding 
} wildcards or globs? is there an option for that? should there be?

There was a long, not-quite-heated discussion of this on the POSIX
standards list ("austin-group") late last year.

The end result of the discussion was that David Korn (as in ksh)
suggested that this should be a line editor operation; that is, you
type some key sequence, and the line editor finds the place between
the rightmost word that starts with a hyphen and the leftmost word
that does not, and inserts "--" there.  I believe PWS even wrote a
function for this and sent it to zsh-users.

No, I'm wrong; I'm thinking of zsh-users/10793, which is for a similar
but not quite identical problem.  However, it should be easy to adapt
that function to do this.


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

end of thread, other threads:[~2007-03-08 17:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-08  4:51 unexpected wildcard issue Atom Smasher
2007-03-08  4:54 ` Dan Nelson
2007-03-08  5:12   ` Atom Smasher
2007-03-08 17:47     ` 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).