However, this also loops endlessly. The reason is most likely that bash
maintains an additional internal variable holding the index of the
current character, relative to the current word. While this variable is
not directly accessible by the user, it is set to 0 whenever OPTIND is
On Wed, Aug 10, 2011 at 18:47, Stephane CHAZELAS stephane_chaze...@yahoo.fr
wrote:
2011-08-10, 12:00(+02), Bernd Eggink:
[...]
function f
{
local OPTIND=1
echo \$1=$1
}
while getopts abcdefg opt
do
echo opt=$opt
f $opt
done
On Wed, Aug 10, 2011 at 6:00 PM, Bernd Eggink mono...@sudrala.de wrote:
On 09.08.2011 15:50, Steven W. Orr wrote:
*) You reset OPTIND to 1 but you didn't declare it local. This will
cause any caller of getlink which uses getopts to reset its variable
to 1. (I mention this because it cost me
2011-08-9, 09:24(+00), Stephane CHAZELAS:
2011-08-9, 11:44(+10), Jon Seymour:
Has anyone ever come across an equivalent to Linux's readlink -f that
is implemented purely in bash?
(I need readlink's function on AIX where it doesn't seem to be available).
[...]
What about:
readlink_f() (
2011-08-09, 11:29(+02), Bernd Eggink:
On 09.08.2011 03:44, Jon Seymour wrote:
Has anyone ever come across an equivalent to Linux's readlink -f that
is implemented purely in bash?
You can find my version here:
http://sudrala.de/en_d/shell-getlink.html
As it contains some corrections
On 09.08.2011 16:54, Stephane CHAZELAS wrote:
2011-08-09, 09:50(-04), Steven W. Orr:
[...]
*) To remove the trailing slashes, instead of
while [[ $file == */ ]]
do
file=${file%/}
done
file=${file##*/}# file name
On 09.08.2011 15:50, Steven W. Orr wrote:
On 8/9/2011 5:29 AM, Bernd Eggink wrote:
On 09.08.2011 03:44, Jon Seymour wrote:
Has anyone ever come across an equivalent to Linux's readlink -f
that is implemented purely in bash?
You can find my version here:
Bob Proulx b...@proulx.com writes:
Same comment here about over-quoting. If nothing else it means that
syntax highlighting is different.
dir=$(cd $(dirname $path); pwd -P)
You are missing a pair of quotes here. :-)
Andreas.
--
Andreas Schwab, sch...@linux-m68k.org
GPG Key
On 09.08.2011 03:44, Jon Seymour wrote:
Has anyone ever come across an equivalent to Linux's readlink -f that
is implemented purely in bash?
You can find my version here:
http://sudrala.de/en_d/shell-getlink.html
As it contains some corrections from Greg Wooledge, it should handle
On 8/9/2011 5:29 AM, Bernd Eggink wrote:
On 09.08.2011 03:44, Jon Seymour wrote:
Has anyone ever come across an equivalent to Linux's readlink -f that
is implemented purely in bash?
You can find my version here:
http://sudrala.de/en_d/shell-getlink.html
As it contains some corrections from
On Tue, Aug 9, 2011 at 7:29 PM, Bernd Eggink mono...@sudrala.de wrote:
On 09.08.2011 03:44, Jon Seymour wrote:
Has anyone ever come across an equivalent to Linux's readlink -f that
is implemented purely in bash?
You can find my version here:
http://sudrala.de/en_d/shell-getlink.html
Has anyone ever come across an equivalent to Linux's readlink -f that
is implemented purely in bash?
(I need readlink's function on AIX where it doesn't seem to be available).
jon.
On Tue, Aug 9, 2011 at 12:49 PM, Bob Proulx b...@proulx.com wrote:
Jon Seymour wrote:
Has anyone ever come across an equivalent to Linux's readlink -f that
is implemented purely in bash?
(I need readlink's function on AIX where it doesn't seem to be available).
Try this:
ls -l
Jon Seymour wrote:
readlink -f will fully resolve links in the path itself (rather than
link at the end of the path), which was the behaviour I needed.
Ah, yes, well, as you could tell that was just a partial solution
anyway.
It seems cd -P does most of what I need for directories and so
On Tue, Aug 9, 2011 at 1:36 PM, Bob Proulx b...@proulx.com wrote:
Jon Seymour wrote:
readlink -f will fully resolve links in the path itself (rather than
link at the end of the path), which was the behaviour I needed.
Ah, yes, well, as you could tell that was just a partial solution
anyway.
Jon Seymour wrote:
I always use sed for this purpose, so:
$(cd $dir; ls -l $base | sed s/.*-//)
But, with pathological linking structures, this isn't quite enough -
particularly if the target of the link itself contains paths, some of
which may contain links :-)
Agreed! Symlinks with
On Tue, Aug 9, 2011 at 2:14 PM, Bob Proulx b...@proulx.com wrote:
Jon Seymour wrote:
I always use sed for this purpose, so:
$(cd $dir; ls -l $base | sed s/.*-//)
But, with pathological linking structures, this isn't quite enough -
particularly if the target of the link itself contains
On Tue, Aug 9, 2011 at 2:36 PM, Jon Seymour jon.seym...@gmail.com wrote:
On Tue, Aug 9, 2011 at 2:14 PM, Bob Proulx b...@proulx.com wrote:
Jon Seymour wrote:
I always use sed for this purpose, so:
$(cd $dir; ls -l $base | sed s/.*-//)
But, with pathological linking structures, this isn't
Jon Seymour wrote:
readlink_f()
{
local path=$1
test -z $path echo usage: readlink_f path 12 exit 1;
An extra ';' there that doesn't hurt but isn't needed.
local dir
if test -L $path
then
local link=$(ls -l $path | sed s/.*- //)
On Tue, Aug 9, 2011 at 2:51 PM, Bob Proulx b...@proulx.com wrote:
Jon Seymour wrote:
readlink_f()
{
local path=$1
test -z $path echo usage: readlink_f path 12 exit 1;
An extra ';' there that doesn't hurt but isn't needed.
local dir
if test -L $path
20 matches
Mail list logo