-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256
I wanted to play with debugging a bash script:
$ echo 'echo hello' > foo
$ bash --debugger foo
hello
$ sudo yum install bashdb -y
...
$ bash --debugger foo
bash debugger, bashdb, release 4.2-0.8
Copyright 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2
On Sat, Nov 22, 2014 at 5:43 AM, Greg Wooledge wrote:
> Well, I did overstate the problem slightly. There are some scenarios
> where you can successfully pass the name of a variable as an argument
> to a function, but they are limited, and you must handle everything
> precisely right.
>
> None of
On Fri, Nov 21, 2014 at 06:21:30AM +0800, konsolebox wrote:
> On Thu, Nov 20, 2014 at 4:47 AM, Greg Wooledge wrote:
> > Passing the name of a variable has NEVER worked in ANY function for ANY
> > purpose in bash.
>
> I hope you're actually not generalizing but you seriously have to reconsider
> t
On Fri, Nov 21, 2014 at 7:13 PM, Stephane Chazelas
wrote:
> Or use
>
> eval "arg=\${$1}"
Yes.
> Or:
>
> eval "arg=\"\${$1}\"" # for ${array[*]}
Yes if allowed.
> which has the benifit to also work with $0, $-, $!, $$,
> ${array[4]} (but obviously not so well with $1, $?, $#, $arg...)
> and as
2014-11-21 10:45:53 +0800, konsolebox:
[...]
> blackbox() {
> [[ $1 == [[:alpha:]_]*([[:alnum:]_]) ]] || return 1 ## Or use
> print_error_message_and_exit().
> declare -n arg=$1; printf '%s\n' "$arg" ## Even just using ${!1}
> would work.
> }
[...]
Or use
eval "arg=\${$1}"
Or:
eval "a