While you have a point with the ksh -n behavioural difference in your
construct I think you should fix how your scripts tackle the quotes.
The problem here is not so much the shell but using the single quotes
around and inside the inline awk program; you switch the quote level
inside awk on shell level. See the results if you put the awk program
/'\''/ {
print "'\''ello, world"
}
in a file of its own, say sq.awk, and use option -f to run it as
echo "'" | awk -f sq.awk
in your script try.sh
Though, to be sure, you should also explain what you intend with
regexp /'\''/ - I suppose you want just
/'/ {
print "'ello, world"
}
Works with ksh and ksh -n.
----------------------------------------
> Date: Wed, 11 Jul 2012 18:44:17 -0400
> From: [email protected]
> To: [email protected]
> Subject: [ast-users] How to keep single quotes from confusing ksh -n
>
> [also posted on stackoverflow at
> http://stackoverflow.com/questions/11442539/how-to-keep-single-quotes-from-confusing-ksh-n
> ]
>
>
> So I have a simple shell script:
>
>
> $ cat try.sh
> #! /bin/ksh
>
> echo "'" | awk '
>
> /'\''/ {
> print "'\''ello, world"
> }
> '
>
>
> and it runs fine:
>
>
> $ ./try.sh
> 'ello, world
>
>
> But "ksh -n" is not altogether happy with it:
>
>
> $ ksh -n ./try.sh
> ./try.sh: warning: line 3: ' quote may be missing
> ./try.sh: warning: line 5: ' quote may be missing
>
>
> I can use tricks (awk variables, awk hex sequences, etc.) to make this
> go away, but surely there's some way to appease the syntax checker (if
> nothing else, for the case when the embedded language has no provision
> for workarounds). What am I forgetting?
>
> Thanks,
> Jeff
>
> P.S. This is happening within a much more complex script and only
> became an issue when I started using nmake to install the file-- nmake
> is running "ksh -n" as part of its intrinsic ruleset.
> _______________________________________________
> ast-users mailing list
> [email protected]
> https://mailman.research.att.com/mailman/listinfo/ast-users
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users