Re: ?maybe? RFE?... read -h ?
.. bash lacks much such smallies On Sun, Sep 5, 2021, 01:21 Greg Wooledge wrote: > On Sat, Sep 04, 2021 at 04:18:09PM -0700, L A Walsh wrote: > > I know how -h can detect a symlink, but I was wondering, is > > there a way for bash to know where the symlink points (without > > using an external program)? > > Nope. > >
Re: ?maybe? RFE?... read -h ?
On Sat, Sep 04, 2021 at 04:18:09PM -0700, L A Walsh wrote: > I know how -h can detect a symlink, but I was wondering, is > there a way for bash to know where the symlink points (without > using an external program)? Nope.
?maybe? RFE?... read -h ?
I know how -h can detect a symlink, but I was wondering, is there a way for bash to know where the symlink points (without using an external program)? Like if I'm running a script and check if something is a symlink to a dir that isn't there, is there a way to read the value of a symlink like a "read -h": chk_val_bin_bash_lnk () { if ! [[ -f /bin/bash ]]; then if [[ -h /bin/bash ]]; then read -h target /bin/bash if [[ $target == /usr/bin/bash ]]; then /bin/mount /usr return 0 fi fi fi return 1 }
Re: LINENO is affected by where it is
On Sat, Sep 04, 2021 at 04:04:05PM -0700, L A Walsh wrote: > LINENO isn't the number of lines executed, but is the > linenumber in the source file it is running in (or the line > in a function for functions already in memory before you > access it. The OP of this thread replied to me that they sovled their problem. I told them that it should be sent to the mailing list as well, but never heard back from them after that. I can't tell whether their private message to me was accidental or not. Anyway, this looks like it was a bug in bash 5.0 which has been fixed in bash 5.1. unicorn:~$ cat foo #!/usr/local/bin/bash-5.0 if true; then echo "Point A: line #$LINENO" (true) echo "Point B: line #$LINENO" fi echo "Point C: line #$LINENO" unicorn:~$ ./foo Point A: line #4 Point B: line #6 Point C: line #6 unicorn:~$ bash-5.1 foo Point A: line #4 Point B: line #6 Point C: line #8 This is my minimal reproducer, based on their note that the trigger is an explicit subshell inside an "if". If the OP has anything else to add, they can chime in.
Re: LINENO is affected by where it is
On 2021/09/01 02:36, David Collier wrote: Version: GNU bash, version 5.0.3(1)-release (arm-unknown-linux-gnueabihf) Raspberry Pi using Raspbian. Installed from repo? LINENO goes backwards when run sync LINENO isn't the number of lines executed, but is the linenumber in the source file it is running in (or the line in a function for functions already in memory before you access it. Some examples: Ishtar:/tmp/d> echoln() { echo "LINENO=$LINENO" } Ishtar:/tmp/d> echoln LINENO=1 Ishtar:/tmp/d> echoln LINENO=1 Ishtar:/tmp/d> echo $LINENO 262 Ishtar:/tmp/d> saveln="val of lineno=$LINENO" Ishtar:/tmp/d> echo run some stuff run some stuff Ishtar:/tmp/d> echo "lineno=$LINENO, not $saveln" lineno=265, not val of lineno=263 echo "== At this point \$LINENO has correctly counted --- LINENO doesn't "count", it is a passive 'count' of where you used the variable "LINENO" (based on some restrictions, like resetting to 1 in functions). Does that clarify anything?