Incoming from Luis Mochan:
> 
> I don't know much about shell programming, but I found that
> /etc/urlhandler/url_handler.sh is a shell script that obtains its url
> doing '$url=$1'. I replaced the whole handler by the following
> program:
>     #! /bin/bash 
>     url=$1; shift
>     echo $url >>tmp.txt; 
> and found out that the url is cut short at the first ampersand. 
> 
> I don't understand why echo by itself yields the correct result (above)
> while echo through a bash script yields the truncated result.

Unix shell handles variables abysmally.  You need to help it a lot to
do the right thing.  *Always* quote variables, else if they're empty
they tend to blow up on you.

  ---------------------------------------------
#!/bin/bash
#
# usage:    gbg.sh "http://url.with/an&ampersand";
#
url="$1"; shift
echo "$url" # >>tmp.txt

exit 0

# Output:

(0) infidel /home/keeling_ sh/gbg.sh "http://url.with/an&ampersand";
http://url.with/an&ampersand
  ---------------------------------------------

HTH.  :-)  Oh, you could do ${1} and ${url} instead, but even they
need to be quoted.


-- 
Any technology distinguishable from magic is insufficiently advanced.
(*)                                                     :(){ :|:& };:
- -

Attachment: signature.asc
Description: Digital signature

Reply via email to