[OE-core] [PATCHv2 3/3] base-files: profile: Simplify setting variables conditionally
Peter Kjellerstedt
peter.kjellerstedt at axis.com
Thu Apr 6 07:21:01 UTC 2017
> -----Original Message-----
> From: Richard Purdie [mailto:richard.purdie at linuxfoundation.org]
> Sent: den 5 april 2017 16:44
> To: Peter Kjellerstedt <peter.kjellerstedt at axis.com>; openembedded-
> core at lists.openembedded.org
> Subject: Re: [OE-core] [PATCHv2 3/3] base-files: profile: Simplify
> setting variables conditionally
>
> On Wed, 2017-04-05 at 15:46 +0200, Peter Kjellerstedt wrote:
> > It is preferred to use `[ <condition> ] || ...` instead of
> > `[ <negated condition> ] && ...` as the latter leaves $? set to 1.
>
> Your patch and the description above don't match. There are changes
> here which aren't <negated condition> and are stylistic changes instead
Well, the intended meaning was that whatever <condition> was used in the
first example should be negated in the second one, not to mean an explicit
negate operator should be used, e.g., if the first <condition> is
[ -z "$VAR" ], the second one would be [ "$VAR" ], not [ ! -z "$VAR" ].
Maybe my examples are just confusing things and I should just remove
them?
> afaict. We're past feature freeze so whilst I'm interested in genuine
> bugs, I do not really want code churn which just introduces risk.
As long as you take the second patch (which is a genuine bug), I am fine
(the first one is pure whitespace clean up, so it should be safe to take
as well).
> Cheers,
>
> Richard
>
> > Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt at axis.com>
> > ---
> > meta/recipes-core/base-files/base-files/profile | 14 ++++++--------
> > 1 file changed, 6 insertions(+), 8 deletions(-)
> >
> > diff --git a/meta/recipes-core/base-files/base-files/profile
> > b/meta/recipes-core/base-files/base-files/profile
> > index ceaf15f799..a062028226 100644
> > --- a/meta/recipes-core/base-files/base-files/profile
> > +++ b/meta/recipes-core/base-files/base-files/profile
> > @@ -3,15 +3,13 @@
> >
> > PATH="/usr/local/bin:/usr/bin:/bin"
> > EDITOR="vi" # needed for packages like
> cron,
> > git-commit
> > -test -z "$TERM" && TERM="vt100" # Basic terminal capab. For
> > screen etc.
> > +[ "$TERM" ] || TERM="vt100" # Basic terminal capab. For
> > screen etc.
> >
> > -if [ "$HOME" = "ROOTHOME" ]; then
> > - PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin
> > -fi
> > -if [ "$PS1" ]; then
> > - # works for bash and ash (no other shells known to be in use
> > here)
> > - PS1='\u@\h:\w\$ '
> > -fi
> > +# Add /sbin & co to $PATH for the root user
> > +[ "$HOME" != "ROOTHOME" ] ||
> > PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin
> > +
> > +# Set the prompt for bash and ash (no other shells known to be in
> > use here)
> > +[ -z "$PS1" ] || PS1='\u@\h:\w\$ '
> >
> > if [ -d /etc/profile.d ]; then
> > for i in /etc/profile.d/*.sh; do
> > --
> > 2.12.0
//Peter
More information about the Openembedded-core
mailing list