From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mediacenter.hi.pengutronix.de ([2001:6f8:1178:2::65]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1S7OkS-00027R-C2 for ptxdist@pengutronix.de; Tue, 13 Mar 2012 11:14:32 +0100 Received: from mol by mediacenter.hi.pengutronix.de with local (Exim 4.72) (envelope-from ) id 1S7OkS-000077-Aw for ptxdist@pengutronix.de; Tue, 13 Mar 2012 11:14:32 +0100 Date: Tue, 13 Mar 2012 11:14:32 +0100 From: Michael Olbrich Message-ID: <20120313101432.GK29221@pengutronix.de> References: <1329252947-118-1-git-send-email-bernhard@bwalle.de> <20120214220510.GQ25569@pengutronix.de> <20120312195617.GA13907@regiomontanus.bwalle.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120312195617.GA13907@regiomontanus.bwalle.de> Subject: Re: [ptxdist] [PATCH] ptxdist: Check for GNU readlink Reply-To: ptxdist@pengutronix.de List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: ptxdist-bounces@pengutronix.de Errors-To: ptxdist-bounces@pengutronix.de To: ptxdist@pengutronix.de On Mon, Mar 12, 2012 at 08:56:17PM +0100, Bernhard Walle wrote: > Hi Michael, > > thanks again for the review. > > * Michael Olbrich [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