From: Mike Gilbert <floppym@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Subject: Re: [gentoo-dev] RFC: esethome
Date: Fri, 15 Jun 2012 10:23:37 -0400 [thread overview]
Message-ID: <CAJ0EP41v_fA0YEFQ41gPAR_db3bcMsui6sceY45x+LGE=mMaUA@mail.gmail.com> (raw)
In-Reply-To: <20120615140554.13398.qmail@stuge.se>
On Fri, Jun 15, 2012 at 10:05 AM, Peter Stuge <peter@stuge.se> wrote:
> Fabian Groffen wrote:
>> > > >>> + if [[ ! -n $(egetent passwd "${euser}") ]] ; then
>> > > >>
>> > > >> "! -n" -> "-z"
>> > > >
>> > > > Does the $() argument ever need to be double quoted, or do all
>> > > > versions of bash actually have the string argument optional even
>> > > > though that's not what the man page reads?
>> > >
>> > > Ever? Yes, but only if what is being returned can contain spaces
>> >
>> > Sorry, I should have mentioned that I had the case of the empty
>> > string in mind.
>>
>> Here for the same reason, the difference between [[ and [ is essential.
>
> It's not clear to me why?
>
> [] is shorthand for test. Both test and [[]] in my man bash read:
>
> --8<--
> Expressions are composed of the primaries described .. under
> CONDITIONAL EXPRESSIONS.
> -->8--
>
> There it says:
> --8<--
> Conditional expressions are used by the [[ compound command and
> the test and [ builtin commands
> -->8--
>
> and:
> --8<--
> -z string
> True if the length of string is zero.
> string
> -n string
> True if the length of string is non-zero.
> -->8--
>
> ..which does not at all make it clear that the string is actually
> optional?
>
> Under Command Substitution it says:
> --8<--
> Embedded newlines are not deleted, but they may be removed during
> word splitting.
> ..
> If the substitution appears within double quotes, word splitting
> and pathname expansion are not performed on the results.
> -->8--
>
> ..confirming that there is some processing of the substitution.
>
>
> I also did the tests before asking the question. I'm not trying to
> say that the code doesn't work on my system. I'm asking if it will
> work the same on every version of bash, in spite of what seems to
> be a conflict between real world and documentation.
>
>
> //Peter
Word splitting does not occur within double brackets. This is
documented in the bash manual.
http://www.gnu.org/software/bash/manual/bashref.html#Conditional-Constructs
This causes empty output from a command substitution within double
brackets to be treated as a zero-length string.
next prev parent reply other threads:[~2012-06-15 14:25 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-13 16:00 [gentoo-dev] RFC: enewuser should force updates to shell and home Ian Stakenvicius
2012-06-13 17:19 ` Michał Górny
2012-06-13 17:21 ` Ian Stakenvicius
2012-06-13 18:45 ` Ian Stakenvicius
2012-06-13 18:47 ` Ian Stakenvicius
2012-06-13 18:09 ` Fabian Groffen
2012-06-13 18:32 ` Ian Stakenvicius
2012-06-13 18:56 ` Mike Gilbert
2012-06-13 19:04 ` Mike Frysinger
2012-06-13 19:11 ` Ian Stakenvicius
2012-06-13 19:14 ` Mike Frysinger
2012-06-13 19:35 ` [gentoo-dev] RFC: esethome Ian Stakenvicius
2012-06-13 20:51 ` Mike Frysinger
2012-06-15 13:16 ` Ian Stakenvicius
2012-06-15 13:27 ` Peter Stuge
2012-06-15 13:35 ` Ian Stakenvicius
2012-06-15 13:39 ` Fabian Groffen
2012-06-15 13:41 ` Peter Stuge
2012-06-15 13:53 ` Fabian Groffen
2012-06-15 14:05 ` Peter Stuge
2012-06-15 14:23 ` Mike Gilbert [this message]
2012-06-15 14:34 ` Peter Stuge
2012-06-13 18:18 ` [gentoo-dev] RFC: enewuser should force updates to shell and home Mike Gilbert
2012-06-13 18:22 ` Samuli Suominen
2012-06-13 18:27 ` Ian Stakenvicius
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAJ0EP41v_fA0YEFQ41gPAR_db3bcMsui6sceY45x+LGE=mMaUA@mail.gmail.com' \
--to=floppym@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox