From: Michael Olbrich <m.olbrich@pengutronix.de>
To: ptxdist@pengutronix.de
Subject: Re: [ptxdist] [PATCH] ptxdist: Check for GNU readlink
Date: Tue, 13 Mar 2012 11:14:32 +0100 [thread overview]
Message-ID: <20120313101432.GK29221@pengutronix.de> (raw)
In-Reply-To: <20120312195617.GA13907@regiomontanus.bwalle.de>
On Mon, Mar 12, 2012 at 08:56:17PM +0100, Bernhard Walle wrote:
> Hi Michael,
>
> thanks again for the review.
>
> * Michael Olbrich <m.olbrich@pengutronix.de> [2012-02-14 23:05]:
> > > +# bash implementation of realpath / readlink -f
> > > +# arg1 - filename
> > > +realpath()
> > > +{
> > > + local fname oldfname
> > > +
> >
> > hmmm, scary.
>
> What's wrong about 'local'?
Not the 'local', the whole function. Getting all corner-cases right for
something like this is not trivial.
> > Another idea: Is the problem that "readlink -f" does not work or does
> > "readlink" not exist at all? Any readlink implementations should work here
> > for fname="$(readlink "${fname}")".
>
> You're right. Even Apple adds a working readlink implementation. :)
>
> > > + if [ "$fname" = . ] ; then
> > > + fname="$(dirname $oldfname)"
> > > + elif echo $fname | grep -vq '^/' - ; then
> >
> > elif [ "${fname}" -eq "${fname#/}" ]; then
>
> -eq is only for numeric comparison, so it should be '=', right?
Right.
>
> > ( cd "$(dirname "${fname}")"
> >
> > > + fname=$(pwd -P)/$(basename $fname)
> >
> > )
>
> Assigning a variable in a subshell has no effect on the outer shell, has
> it? But echo'ing directly here works.
True. We want to echo anyways.
> A reworked version will follow.
Michael
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
--
ptxdist mailing list
ptxdist@pengutronix.de
next prev parent reply other threads:[~2012-03-13 10:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-14 20:55 Bernhard Walle
2012-02-14 22:05 ` Michael Olbrich
2012-03-12 19:56 ` Bernhard Walle
2012-03-13 10:14 ` Michael Olbrich [this message]
2012-03-13 11:32 ` Bernhard Walle
2012-03-13 10:16 [ptxdist] [PATCH 2/2] " Michael Olbrich
2012-03-13 11:23 ` [ptxdist] [PATCH] " bernhard
2012-03-13 11:30 ` bernhard
2012-03-13 13:17 ` Michael Olbrich
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=20120313101432.GK29221@pengutronix.de \
--to=m.olbrich@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