From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andreas Engel Date: Mon, 22 Aug 2005 15:01:36 +0200 Subject: [U-Boot-Users] test variable existence in hush In-Reply-To: <20050822122158.426BA352B0C@atlas.denx.de> References: <20050822125758.00001da8@idefix> <20050822122158.426BA352B0C@atlas.denx.de> Message-ID: <20050822150136.000060fb@idefix> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Mon, 22 Aug 2005 14:21:58 +0200 Wolfgang Denk wrote: >I cannot confirm this. The only part of hush which is involved here >is the && processing which works fine for me.. > >"test" is NOT a hush builtin. I hit the send button too early... Yes, "test" is not a hush builtin, but it is only available if the hush parser is enabled. >Sure: > >TRAB # foo= >TRAB # test -n "$foo" && echo yes >TRAB # test -n "$foo" || echo no >no >TRAB # test "$foo" && echo yes >TRAB # test "$foo" || echo no >no >TRAB # foo=dummy >TRAB # test -n "$foo" && echo yes >yes >TRAB # test -n "$foo" || echo no >TRAB # test "$foo" && echo yes >TRAB # test "$foo" || echo no >no > >THe only problem I see is with "test -z": > > TRAB # foo= > TRAB # test -z "$foo" && echo yes > TRAB # test -z "$foo" || echo no > no >but > TRAB # test -z "" && echo yes > yes > TRAB # test -z "" || echo no > TRAB # No, I think this is misleading. A quick debugging session showed that the problem is not the "test" command itself. With 'test -z ""' and 'test -n ""', the command will correctly see three arguments. However, with 'test -n "$foo"' and 'test -z "$foo"' (and empty $foo), the command will only get two arguments which always results in a return value of 1. That's why 'test -n' seems to work. Regards, Andreas Engel