sean finney on 13 Oct 2009 15:22:45 -0700 |
On Tue, Oct 13, 2009 at 05:19:26PM -0400, Paul L. Snyder wrote: > How about this, which should be POSIX-compliant (and doesn't require a > subshell): > > % foo=bar > % if [[ -z ${foo+isset} ]]; then echo nope; else echo yep; fi > yep > % foo='' > % if [[ -z ${foo+isset} ]]; then echo nope; else echo yep; fi > yep > % unset foo > % if [[ -z ${foo+isset} ]]; then echo nope; else echo yep; fi > nope > > 'isset' doesn't matter, it could be any non-zero-length string. i hate to tell ya, but i'm pretty sure "[[" is also non-posix :) if in doubt, install ksh, dash, and posh. they are forgiving in approximately descending order :) sean Attachment:
signature.asc ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug
|
|