Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!lll-tis!ames!pacbell!att-ih!cuuxb!ltuxa!ll1a!spl1!laidbak!daveb From: daveb@laidbak.UUCP (Dave Burton) Newsgroups: comp.unix.xenix Subject: Re: trouble with expr Message-ID: <1369@laidbak.UUCP> Date: 11 Mar 88 02:45:58 GMT References: <717@yabbie.rmit.oz> <113@hawkmoon.MN.ORG> Reply-To: daveb@laidbak.UUCP (Dave Burton) Organization: is pretty bad/My method of Lines: 31 Keywords: expr,sco xenix,bug(?) In article <113@hawkmoon.MN.ORG> det@hawkmoon.MN.ORG (Derek E. Terveer) writes: >The man page states that multiplication is performed by escaping (using a >backslash) the asterisk. Try this: And of course the reason is: the shell will expand that little hummer, then it won't be a star any more. Sorry if you know this Derek, but you make it sound like magic. There is nothing magical about the backslash. The mystery comes from the shell. >$ expr 2 \* 3 >6 Because expr saw (quotes are mine): '2', '*', '3' >$ expr "2 * 3" >2 * 3 Because expr saw '2 * 3' (one argument, not three) >$ expr "2 \* 3" >2 \* 3 Becuase expr saw '2 \* 3' (the backslash is protected inside double quotes) >$ expr 2 * 3 >expr: syntax error Because expr saw something like '2', 'foo', 'bar', 'etc', '3'. More fun: expr 2 '*' 3 = 6 expr 2 "*" 3 = 6 star=*; expr 2 "$star" 3 = 6 -- --------------------"Well, it looked good when I wrote it"--------------------- Verbal: Dave Burton Net: ...!ihnp4!laidbak!daveb V-MAIL: (312) 505-9100 x325 USSnail: 1901 N. Naper Blvd. #include Naperville, IL 60540