Johannes Meixner
Johannes Meixner
A 'nit' reply only for the fun of it: I prefer `1>` over `>` because I prefer explicit code. In particular explicit `1>` would make it easier in theory to...
Sigh - endless problems - here the next one: We cannot fail when 'source' fails because 'source' returns the status of the last command executed in the sourced file so...
What seems to behave correctly (at least for me with what I test here) is ``` # function get_var_from_file() { bash -c 'source "$0" >/dev/null ; set -u ; echo...
@pcahyna in your https://github.com/rear/rear/pull/3171#discussion_r1521750947 you wrote that "the get_var_from_file function is meant to be generic" which was the reason that I suggested in my https://github.com/rear/rear/pull/3171#discussion_r1523283636 that "it fits perhaps better...
It also fails for file not found or not readable ``` # function get_var_from_file() { bash -c 'source "$0" >/dev/null ; set -u ; echo "${!1}"' "$1" "$2" || return...
Bottom line of what I mean is: As far as I see ``` function get_var_from_file() { bash -c 'source "$0" >/dev/null ; set -u ; echo "${!1}"' "$1" "$2" ||...
For the fun of craziness: My above described simple "all or nothing" return code behaviour does not hold in any case, in particular not for shell variables: ``` # cat...
@pcahyna @lzaoral when you agree that having a generic function ``` function get_var_from_file() { bash -c 'unset $1 || exit 1 ; source "$0" >/dev/null ; set -u ; echo...
FYI: How it behaves for /etc/os-release for me ``` # for varname in $( cut -s -d '=' -f1 /etc/os-release ) ; \ do unset myvar ; \ if myvar="$(...
@pcahyna my pleasure: https://github.com/rear/rear/pull/3203