On Thu, Aug 10, 2006 at 07:19:11PM -0500, Jacob Yocom-Piatt wrote:
> 
> thx for the suggestions all, i've fixed the issue. the trouble was that i had 
> an
> if statement that was evaluating $ADMIN like so:
> 
> if [[ $ADMIN -ne "" ]]; then
> 
> this likely had the @ being interpreted as a regexp.

  the /closest/ thing i'm aware of wrt the '@' being interpreted as
  a regex by ksh would be in filename patterns - but even then, it only
  indicates that the stuff following in the ERE-like '(a|b|c)'
  construct should be matched by a literal exact 'a' or 'b' or 'c', 
  it's not doing regular expression magics.  

  in your [[ $ADMIN ]] thing, there's no regexing happening.

  '-ne' is for algebraic integer comparison.  '!=' would be a better
  choice for strings.

  '!=' makes your if '[[ $ADMIN <is not equal to> "" ]]' test work:

------------------------------------------
$ set -xv
$ [EMAIL PROTECTED]
[EMAIL PROTECTED]
+ [EMAIL PROTECTED]
$ [[ $JOE -ne "" ]] && echo =====
[[ $JOE -ne "" ]] && echo =====
/bin/ksh: [EMAIL PROTECTED]: unexpected `@'
$ [[ $JOE != "" ]] && echo =====
[[ $JOE != "" ]] && echo =====
+ echo =====
=====
------------------------------------------

  in other words, the unexpected '@' is not the '@'s fault. 

  i imagine what might be happening is ksh sees '-ne' and knows
  it should be treating the operands (?) as integers; it tries 
  to evaluate the integer value of '[EMAIL PROTECTED]' and dies.

------------------------------------------
$ set -xv
$ echo $(( blah ))
echo $(( blah ))
+ echo 0
0
[/tmp_mnt/doublewide/home/jrrs] $ echo $(( [EMAIL PROTECTED] ))
echo $(( [EMAIL PROTECTED] ))
/bin/ksh:  [EMAIL PROTECTED] : unexpected `@'
------------------------------------------
 
  if i understand correctly, in the first place, 'blah' is simply
  being treated as an integer constant who happens to equal 0.

  'echo $(( poo)poo ))' gives 'unexpected `)''.  it's just that
  some character happened that made ksh say "oh, as i parse these
  characters, now i reach something that means i'm not looking
  at the name of the integer constant anymore, let me see if i know
  what it could be?', and since '@' is not a valid operator or
  anything else that makes sense to ksh in an arithmetic context,
  it pukes.

  last illustration, beg your pardon:

------------------------------------------
$ set -xv
$ LOU=1+1
LOU=1+1
+ LOU=1+1
$ echo x${LOU}x
echo x${LOU}x
+ echo x1+1x
x1+1x
$ [[ $LOU -ne 3 ]] && echo hi
[[ $LOU -ne 3 ]] && echo hi
+ echo hi
hi
$ [[ $LOU -ne 2 ]] && echo hi
[[ $LOU -ne 2 ]] && echo hi
$ [[ $LOU -ne 1 ]] && echo hi
[[ $LOU -ne 1 ]] && echo hi
+ echo hi
hi
------------------------------------------

  should make it clear what's happening, if you'll also pardon the
  xtrace/verbose.

  i don't know why i see people escaping the '@' so much in regexes.
  the '@' has no special meaning in a BRE or an ERE ( as illustration,
  there are no '@'s in regex(3), regexp(3), re_format(7), or grep(1) ).

  i'd venture to say that '@' is the most frequently unnecessarily
  escaped character in ascii(7).

-- 

  jared

[ openbsd 3.9-current GENERIC ( jul 29 ) // i386 ]

Reply via email to