mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: ptxdist@pengutronix.de
Subject: Re: [ptxdist] [PATCH 2/3] rc-once: Use readlink to check where /system-update points to.
Date: Tue, 6 Jun 2017 23:54:34 +0200	[thread overview]
Message-ID: <20170606215434.v3sazbtiwgwndhff@pengutronix.de> (raw)
In-Reply-To: <20170606164908.hyw7tbzbea7ahv2c@pengutronix.de>

Hello Michael,

On Tue, Jun 06, 2017 at 06:49:08PM +0200, Michael Olbrich wrote:
> On Tue, Jun 06, 2017 at 06:25:09PM +0200, Uwe Kleine-König wrote:
> > On Tue, Jun 06, 2017 at 06:00:51PM +0200, Michael Olbrich wrote:
> > > On Tue, Jun 06, 2017 at 05:28:48PM +0200, Gavin Schenk wrote:
> > > > rc-once ist based on systemd offline update mechanism.
> > > > https://www.freedesktop.org/software/systemd/man/systemd.offline-updates
> > > > 
> > > > To make it possible to have multiple update services beside rc-once the
> > > > script should check where the link /system-update points to.
> > > > 
> > > > rc-once will only run if the link points to etc/rc-once.d or
> > > > /etc/rc-once.d.
> > > > 
> > > > Signed-off-by: Gavin Schenk <g.schenk@eckelmann.de>
> > > > ---
> > > >  projectroot/usr/lib/init/rc-once.sh | 5 +++++
> > > >  rules/rc-once.in                    | 3 +++
> > > >  2 files changed, 8 insertions(+)
> > > > 
> > > > diff --git a/projectroot/usr/lib/init/rc-once.sh b/projectroot/usr/lib/init/rc-once.sh
> > > > index 8689a32bc..d225ad5c2 100644
> > > > --- a/projectroot/usr/lib/init/rc-once.sh
> > > > +++ b/projectroot/usr/lib/init/rc-once.sh
> > > > @@ -6,6 +6,11 @@ STAMP="$DONE_DIR/rc-once"
> > > >  
> > > >  run_rc_once() {
> > > >  	failed=0
> > > > +	UPDATE_TARGET=$(readlink -f /system-update)
> > > 
> > > This needs quotes in case the link target contains spaces.
> > 
> > I think that's wrong. It only needs quoting when being used:
> > 
> > 	$ cat test.sh 
> > 	#!/bin/sh
> > 
> > 	tmpdir=$(mktemp -d)
> > 
> > 	touch "$tmpdir/file with	spaces";
> > 
> > 	FILE=$(ls $tmpdir)
> > 
> > 	echo "$FILE"
> > 
> > 	rm -rf $tmpdir
> > 
> > 	$ bash test.sh  | hexdump -C
> > 	00000000  66 69 6c 65 20 77 69 74  68 09 73 70 61 63 65 73  |file with.spaces|
> > 	00000010  0a                                                |.|
> > 	00000011
> > 
> > That being said, quotes don't hurt either.
> 
> This is strange. I see the same thing, but the bash man-page says:
> "If the substitution appears within double quotes, word splitting and
> pathname expansion are not performed on the results."
> So I'd assume, that word splitting and pathname expansion are performed if
> no quotes are used, but that doesn't seem to happen.

They are, but only if these are applied in the current context. For
variable assignment we have:

	A variable may be assigned to by a statement of the form

		name=[value]

	[...] All values undergo tilde expansion, parameter and variable
	expansion, command substitution, arithmetic expansion, and quote
	removal [...].

The quotes are indeed important if you do:

	somecommand $(ls $tmpdir)

which in the setup of my script above would pass three arguments to
somecommand while

	somecommand "$(ls $tmpdir)"

would only result in a single argument.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

  reply	other threads:[~2017-06-06 21:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-06 15:28 [ptxdist] [PATCH 0/3] Using second offline update service beside rc-once in PTXDIST Gavin Schenk
2017-06-06 15:28 ` [ptxdist] [PATCH 1/3] rc-once: Use /etc/rc.once.d as link target in all rc-once scripts Gavin Schenk
2017-06-06 15:58   ` Michael Olbrich
2017-06-06 15:28 ` [ptxdist] [PATCH 2/3] rc-once: Use readlink to check where /system-update points to Gavin Schenk
2017-06-06 16:00   ` Michael Olbrich
2017-06-06 16:25     ` Uwe Kleine-König
2017-06-06 16:49       ` Michael Olbrich
2017-06-06 21:54         ` Uwe Kleine-König [this message]
2017-06-06 15:28 ` [ptxdist] [PATCH 3/3] rc-once: Moved deletion of /system-update into function run_rc_once() Gavin Schenk
2017-06-06 16:02   ` Michael Olbrich
2017-06-07  6:29     ` Schenk, Gavin

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=20170606215434.v3sazbtiwgwndhff@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=ptxdist@pengutronix.de \
    /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