zsh-users
 help / color / mirror / code / Atom feed
* zsh-4.04 and w3m browser
@ 2002-08-28 11:23 Arthur Alinovi
  2002-08-28 11:27 ` Peter Stephenson
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Arthur Alinovi @ 2002-08-28 11:23 UTC (permalink / raw)
  To: zsh-users

I have just started using zsh-4.04 and am having some problems with the
w3m text based web browser.

If I copy a url, then type:

w3m <paste url I copied>

zsh comes back with:

zsh: no matches found: <url I pasted>

Is there a way around this, or do I constantly have to switch into ksh
before using w3m?

Thanks


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

* Re: zsh-4.04 and w3m browser
  2002-08-28 11:23 zsh-4.04 and w3m browser Arthur Alinovi
@ 2002-08-28 11:27 ` Peter Stephenson
  2002-08-28 11:28 ` Roman Neuhauser
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 13+ messages in thread
From: Peter Stephenson @ 2002-08-28 11:27 UTC (permalink / raw)
  To: Arthur Alinovi, Zsh users list

Arthur Alinovi wrote:
> If I copy a url, then type:
> 
> w3m <paste url I copied>
> 
> zsh comes back with:
> 
> zsh: no matches found: <url I pasted>

The easiest way to avoid this is to put `setopt nonomatch' in your
~/.zshrc or ~/.zshenv.  However, given that the URL contains special
characters (which are triggering the message) it would be safer to put
single quotes around it.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


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

* Re: zsh-4.04 and w3m browser
  2002-08-28 11:23 zsh-4.04 and w3m browser Arthur Alinovi
  2002-08-28 11:27 ` Peter Stephenson
@ 2002-08-28 11:28 ` Roman Neuhauser
  2002-08-28 11:30 ` Sven Wischnowsky
  2002-08-28 11:36 ` Thomas Köhler
  3 siblings, 0 replies; 13+ messages in thread
From: Roman Neuhauser @ 2002-08-28 11:28 UTC (permalink / raw)
  To: zsh-users

> To: zsh-users@sunsite.dk
> Subject: zsh-4.04 and w3m browser
> Date: Wed, 28 Aug 2002 07:23:30 -0400
> From: Arthur Alinovi <aalinovi@panix.com>
> 
> I have just started using zsh-4.04 and am having some problems with the
> w3m text based web browser.
> 
> If I copy a url, then type:
> 
> w3m <paste url I copied>
> 
> zsh comes back with:
> 
> zsh: no matches found: <url I pasted>
> 
> Is there a way around this, or do I constantly have to switch into ksh
> before using w3m?

    the url contains shell metacharacters which make zsh think it's a
    glob, and it tries to expand it.

-- 
FreeBSD 4.6-STABLE
1:27PM up 7 days, 19:20, 17 users, load averages: 0.00, 0.00, 0.00


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

* Re: zsh-4.04 and w3m browser
  2002-08-28 11:23 zsh-4.04 and w3m browser Arthur Alinovi
  2002-08-28 11:27 ` Peter Stephenson
  2002-08-28 11:28 ` Roman Neuhauser
@ 2002-08-28 11:30 ` Sven Wischnowsky
  2002-08-28 11:36 ` Thomas Köhler
  3 siblings, 0 replies; 13+ messages in thread
From: Sven Wischnowsky @ 2002-08-28 11:30 UTC (permalink / raw)
  To: zsh-users


Arthur Alinovi wrote:

> I have just started using zsh-4.04 and am having some problems with the
> w3m text based web browser.
> 
> If I copy a url, then type:
> 
> w3m <paste url I copied>
> 
> zsh comes back with:
> 
> zsh: no matches found: <url I pasted>
> 
> Is there a way around this, or do I constantly have to switch into ksh
> before using w3m?

It's interpreting the URL as a glob pattern. You can avoid this by
quoting the URL. Probably better is to use the noglob precommand
modifier and an alias to avoid having to type that in again and again:

  alias 'w3m=noglob w3m'



Bye
  Sven

-- 
Sven Wischnowsky                          wischnow@berkom.de


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

* Re: zsh-4.04 and w3m browser
  2002-08-28 11:23 zsh-4.04 and w3m browser Arthur Alinovi
                   ` (2 preceding siblings ...)
  2002-08-28 11:30 ` Sven Wischnowsky
@ 2002-08-28 11:36 ` Thomas Köhler
  2002-08-28 12:18   ` Vincent Lefevre
  3 siblings, 1 reply; 13+ messages in thread
From: Thomas Köhler @ 2002-08-28 11:36 UTC (permalink / raw)
  To: zsh-users

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

Arthur Alinovi wrote [2002/08/28 13:26]:
> I have just started using zsh-4.04 and am having some problems with the
> w3m text based web browser.
> 
> If I copy a url, then type:
> 
> w3m <paste url I copied>
> 
> zsh comes back with:
> 
> zsh: no matches found: <url I pasted>
> 
> Is there a way around this, or do I constantly have to switch into ksh
> before using w3m?

alias w3m="noglob w3m"

I use the same with lynx :-)

Ciao,
Thomas

-- 
 Thomas Köhler Email:   jean-luc@picard.franken.de     | LCARS - Linux
     <><        WWW:     http://jeanluc-picard.de      | for Computers
                IRC:             jeanluc               | on All Real
               PGP public key available from Homepage! | Starships

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: zsh-4.04 and w3m browser
  2002-08-28 11:36 ` Thomas Köhler
@ 2002-08-28 12:18   ` Vincent Lefevre
  2002-08-28 12:50     ` Peter Stephenson
  0 siblings, 1 reply; 13+ messages in thread
From: Vincent Lefevre @ 2002-08-28 12:18 UTC (permalink / raw)
  To: zsh-users

On Wed, Aug 28, 2002 at 13:36:55 +0200, Thomas Köhler wrote:
> alias w3m="noglob w3m"
> 
> I use the same with lynx :-)

But this wouldn't work if you want to mix URIs and filenames for
some arbitrary program. Shouldn't globbing be smarter (possibly
as an option)? For instance, when a word starts with "http:" or
"ftp:", globbing shouldn't be performed. "file:" could be treated
in a special way: for localhost, globbing should be performed and
completion should work.

-- 
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/> - 100%
validated (X)HTML - Acorn Risc PC, Yellow Pig 17, Championnat International
des Jeux Mathématiques et Logiques, TETRHEX, etc.
Work: CR INRIA - computer arithmetic / SPACES project at LORIA


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

* Re: zsh-4.04 and w3m browser
  2002-08-28 12:18   ` Vincent Lefevre
@ 2002-08-28 12:50     ` Peter Stephenson
  2002-08-28 13:08       ` Vincent Lefevre
  0 siblings, 1 reply; 13+ messages in thread
From: Peter Stephenson @ 2002-08-28 12:50 UTC (permalink / raw)
  To: Zsh users list

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1416 bytes --]

Vincent Lefevre wrote:
> On Wed, Aug 28, 2002 at 13:36:55 +0200, Thomas Köhler wrote:
> > alias w3m="noglob w3m"
> > 
> > I use the same with lynx :-)
> 
> But this wouldn't work if you want to mix URIs and filenames for
> some arbitrary program. Shouldn't globbing be smarter (possibly
> as an option)? For instance, when a word starts with "http:" or
> "ftp:", globbing shouldn't be performed. "file:" could be treated
> in a special way: for localhost, globbing should be performed and
> completion should work.

This is virtually the same as what `setopt nonomatch' does, assuming you
don't have files with names beginning http: or ftp:.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


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

* Re: zsh-4.04 and w3m browser
  2002-08-28 12:50     ` Peter Stephenson
@ 2002-08-28 13:08       ` Vincent Lefevre
  2002-08-28 15:25         ` Bart Schaefer
  0 siblings, 1 reply; 13+ messages in thread
From: Vincent Lefevre @ 2002-08-28 13:08 UTC (permalink / raw)
  To: Zsh users list

On Wed, Aug 28, 2002 at 13:50:52 +0100, Peter Stephenson wrote:
> This is virtually the same as what `setopt nonomatch' does, assuming you
> don't have files with names beginning http: or ftp:.

except that I really don't like nonomatch, so I won't use it (unless
one can apply nonomatch only to some patterns, e.g. to words starting
with http: or ftp:).

-- 
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/> - 100%
validated (X)HTML - Acorn Risc PC, Yellow Pig 17, Championnat International
des Jeux Mathématiques et Logiques, TETRHEX, etc.
Work: CR INRIA - computer arithmetic / SPACES project at LORIA


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

* Re: zsh-4.04 and w3m browser
  2002-08-28 13:08       ` Vincent Lefevre
@ 2002-08-28 15:25         ` Bart Schaefer
  2002-08-28 15:33           ` Vincent Lefevre
  2002-08-30  5:31           ` Bart Schaefer
  0 siblings, 2 replies; 13+ messages in thread
From: Bart Schaefer @ 2002-08-28 15:25 UTC (permalink / raw)
  To: Vincent Lefevre, Zsh users list

On Aug 28,  3:08pm, Vincent Lefevre wrote:
} Subject: Re: zsh-4.04 and w3m browser
}
} except that I really don't like nonomatch, so I won't use it (unless
} one can apply nonomatch only to some globterns, e.g. to words starting
} with http: or ftp:).

Minimally tested, but seems to work:

---- 8< ---- snip ---- 8< ----
function urlglobber {
    local -a args globbed
    local arg command="$1"
    shift
    for arg
    do
	case "${arg}" in
	(ftp://(|localhost)/*)
	    globbed=( ${~${arg##ftp://(|localhost)}} )
	    args[$#args+1]=( "${(M)arg##ftp://(|localhost)}${(@)^globbed}" )
	    ;;
	((http(|s)|ftp):*) args[$#args+1]="$arg";;
	(*) args[$#args+1]=( ${~arg} );;
	esac
    done
    "$command" "${(@)args}"
}
alias globurl='noglob urlglobber'
alias ncftp='globurl ncftp'
alias lynx='globurl lynx'
alias w3m='globurl w3m'
---- 8< ---- snip ---- 8< ----

Other cases, such as <http://localhost/globbed?unglobbed>, are left as an
excercise for the reader.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

* Re: zsh-4.04 and w3m browser
  2002-08-28 15:25         ` Bart Schaefer
@ 2002-08-28 15:33           ` Vincent Lefevre
  2002-08-28 15:52             ` Bart Schaefer
  2002-08-28 16:48             ` Wayne Davison
  2002-08-30  5:31           ` Bart Schaefer
  1 sibling, 2 replies; 13+ messages in thread
From: Vincent Lefevre @ 2002-08-28 15:33 UTC (permalink / raw)
  To: Zsh users list

On Wed, Aug 28, 2002 at 15:25:00 +0000, Bart Schaefer wrote:
> ---- 8< ---- snip ---- 8< ----
> function urlglobber {
>     local -a args globbed
>     local arg command="$1"
>     shift
>     for arg
>     do
> 	case "${arg}" in
> 	(ftp://(|localhost)/*)
> 	    globbed=( ${~${arg##ftp://(|localhost)}} )
> 	    args[$#args+1]=( "${(M)arg##ftp://(|localhost)}${(@)^globbed}" )
> 	    ;;
> 	((http(|s)|ftp):*) args[$#args+1]="$arg";;
> 	(*) args[$#args+1]=( ${~arg} );;
> 	esac
>     done
>     "$command" "${(@)args}"
> }
> alias globurl='noglob urlglobber'
> alias ncftp='globurl ncftp'
> alias lynx='globurl lynx'
> alias w3m='globurl w3m'
> ---- 8< ---- snip ---- 8< ----

But how to make it work for any command? (and that should work even
when there are pipes and so on.)

-- 
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/> - 100%
validated (X)HTML - Acorn Risc PC, Yellow Pig 17, Championnat International
des Jeux Mathématiques et Logiques, TETRHEX, etc.
Work: CR INRIA - computer arithmetic / SPACES project at LORIA


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

* Re: zsh-4.04 and w3m browser
  2002-08-28 15:33           ` Vincent Lefevre
@ 2002-08-28 15:52             ` Bart Schaefer
  2002-08-28 16:48             ` Wayne Davison
  1 sibling, 0 replies; 13+ messages in thread
From: Bart Schaefer @ 2002-08-28 15:52 UTC (permalink / raw)
  To: Vincent Lefevre, Zsh users list

On Aug 28,  5:33pm, Vincent Lefevre wrote:
} 
} But how to make it work for any command?

There is no answer but the facetious one:

for x in ${^path}*(Nx); do alias "${x:t}=globurl $x"; done

Shells are simply not designed to "think" in terms of URLs.  For one thing,
nearly every character that's a metacharacter in a URL is also a metachar
to the shell.  Ampersand is the most extreme example -- there is NO way
for the shell to know whether it means to separate commands or to separate
query parameters.  It's not worth the effort to make the built-in globber
"understand" URL scheme prefixes.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

* Re: zsh-4.04 and w3m browser
  2002-08-28 15:33           ` Vincent Lefevre
  2002-08-28 15:52             ` Bart Schaefer
@ 2002-08-28 16:48             ` Wayne Davison
  1 sibling, 0 replies; 13+ messages in thread
From: Wayne Davison @ 2002-08-28 16:48 UTC (permalink / raw)
  To: Vincent Lefevre; +Cc: Zsh users list

On Wed, 28 Aug 2002, Vincent Lefevre wrote:
> But how to make it work for any command? (and that should work even
> when there are pipes and so on.)

If there were some way to run a shell function after the user hits
return but before the line is parsed, it would be possible for the
function to add single quotes to all the strings of non-spaces that
start with http: (assuming that the command-line was in a variable
that could be modified).

..wayne..


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

* Re: zsh-4.04 and w3m browser
  2002-08-28 15:25         ` Bart Schaefer
  2002-08-28 15:33           ` Vincent Lefevre
@ 2002-08-30  5:31           ` Bart Schaefer
  1 sibling, 0 replies; 13+ messages in thread
From: Bart Schaefer @ 2002-08-30  5:31 UTC (permalink / raw)
  To: Vincent Lefevre, Zsh users list

On Aug 28,  3:25pm, Bart Schaefer wrote:
}
} Minimally tested, but seems to work:

Actually there was a bug, which is that even with ${var##pat} it's not
necessarily the case that the longest pattern will be matched when the
pattern contains alternatives with (|) -- because that form tries each
alternative in order, and stops when one matches.

So the right formulation is (only two of the `|' have moved):

---- 8< ---- snip ---- 8< ----
function urlglobber {
    local -a args globbed
    local arg command="$1"
    shift
    for arg
    do
	case "${arg}" in
	(ftp://(|localhost)/*)
	    globbed=( ${~${arg##ftp://(localhost|)}} )
	    args[$#args+1]=( "${(M)arg##ftp://(localhost|)}${(@)^globbed}" )
	    ;;
	((http(|s)|ftp):*) args[$#args+1]="$arg";;
	(*) args[$#args+1]=( ${~arg} );;
	esac
    done
    "$command" "${(@)args}"
}
alias globurl='noglob urlglobber'
---- 8< ---- snip ---- 8< ----

However, I had another thought about a possible approach to handling URLs
in shell input:

---- 8< ---- snip ---- 8< ----
function url-magic-space {
    local words
    words=("${(@Q)${(q)=LBUFFER}}") 
    case "$words[-1]" in
    (*[\'\"]*) ;;
    (ftp://(|localhost)/(~|*([][?#*]|\(|\)))*)
	local left="${(qqM)${words[-1]}##ftp://(localhost|)}"
	local right="${${words[-1]}##ftp://(localhost|)}"
	right="${right/#\/~/~}"
	words[-1]="$left"'"${(f)^$(print -lr -- '"$right"')}"' ;;
    (http(|s)|ftp):*) words[-1]="${(qq)words[-1]}" ;;
    esac
    LBUFFER="${(j: :)words}" 
    zle self-insert		# Or  zle magic-space  if you prefer ...
}
zle -N url-magic-space
bindkey ' ' url-magic-space
---- 8< ---- snip ---- 8< ----

When SPACE is pressed, the widget above rewrites e.g.

    zsh% echo ftp://localhost/~/*

into

    zsh% echo ftp://localhost"${(f)^$(print -lr -- ~/*)}" 

which should have the desired end result (unless you have file names with
embedded newlines), even if it's not so readable.

It also turns

    zsh% lynx http://somewhere.com/something.cgi?x=1&y=2&so=on

into

    zsh% lynx 'http://somewhere.com/something.cgi?x=1&y=2&so=on' 

(that is, it adds the quotes for you) and it is clever enough to try not
to mess with a word that already uses quotes (though that too might be
improved a little bit with a lot of effort).

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

end of thread, other threads:[~2002-08-30  5:32 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-28 11:23 zsh-4.04 and w3m browser Arthur Alinovi
2002-08-28 11:27 ` Peter Stephenson
2002-08-28 11:28 ` Roman Neuhauser
2002-08-28 11:30 ` Sven Wischnowsky
2002-08-28 11:36 ` Thomas Köhler
2002-08-28 12:18   ` Vincent Lefevre
2002-08-28 12:50     ` Peter Stephenson
2002-08-28 13:08       ` Vincent Lefevre
2002-08-28 15:25         ` Bart Schaefer
2002-08-28 15:33           ` Vincent Lefevre
2002-08-28 15:52             ` Bart Schaefer
2002-08-28 16:48             ` Wayne Davison
2002-08-30  5:31           ` 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).