Feature request - make type show that a builtin is a loadable

2022-10-23 Thread Geir Hauge
tions, which could potentially leave out some function the loadable builtin expects to use. -- Geir Hauge diff --git a/builtins.h b/builtins.h index 01565935..b4c71274 100644 --- a/builtins.h +++ b/builtins.h @@ -57,6 +57,7 @@ struct builtin { char * const *long_doc; /* NULL terminated arra

cut loadable outputs extra newlines

2022-08-10 Thread Geir Hauge
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: darwin20.6.0 Compiler: gcc Compilation CFLAGS: -g -O2 uname output: Darwin macspear 20.6.0 Darwin Kernel Version 20.6.0: Tue Apr 19 2$ Machine Type: x86_64-apple-darwin20.6.0 Bash Version: 5.2 Patch Level: 0 Re

Can't wait for process substitution redirected for a subshell

2018-04-24 Thread Geir Hauge
: $ time bash -c '(echo "subshell \$! = $!"; wait "$!") 2> >(echo "procsub pid = $BASHPID"; sleep 2)' subshell $! = 74756 procsub pid = 74756 2.014 I get the same behavior with both 4.4.19 and the latest devel snapshot -- Geir Hauge

Re: ~/.profile and ~/.bash_profile aren't executed on login

2017-12-10 Thread Geir Hauge
e in addition to ~/.profile. Assuming this is the case, I suggest you merge whatever it contains into ~/.profile, and remove the ~/.bash_profile file. -- Geir Hauge

Re: Trailing newlines disappear

2017-06-08 Thread Geir Hauge
can pick one of these instead: mapfile < "$file"; IFS= foo="${MAPFILE[*]}"; unset -v IFS or mapfile < "$file"; printf -v foo %s "${MAPFILE[@]}" -- Geir Hauge

Re: -eq and strings

2017-03-06 Thread Geir Hauge
hould be slightly faster than your -eq hack. is_digit() { [[ -n $1 && $1 != *[![:digit:]]* ]]; } or the sh variant: is_digit() { case $1 in ''|*[![:digit:]]*) return 1;; esac; } See also http://mywiki.wooledge.org/BashFAQ/054 -- Geir Hauge

Re: bash "while do echo" can't function correctly

2016-04-12 Thread Geir Hauge
eferred over echo: while read -r line; do printf '%s\n' "$line"; done < test.txt -- Geir Hauge

read -a ignores upper- and lowercase flags

2016-04-08 Thread Geir Hauge
read -ra c <<< "HEllO woRLd" mapfile d <<< "HEllO woRLd" declare -p a b c d Output: declare -al a=([0]="hello" [1]="world") declare -l b="hello world" declare -al c=([0]="HEllO" [1]="woRLd") declare -al d=([0]=$'hello world\n') -- Geir Hauge

Re: trap DEBUG and $_

2015-10-12 Thread Geir Hauge
> Any suggestions? > > > > Thanks! > > > trap '__=$_; preexec; : "$__"' DEBUG And since the preexec function ignores its arguments, it can be shortened to: trap 'preexec "$_"' DEBUG -- Geir Hauge

Re: read and env variables + POSIX => SEGFAULT

2015-10-11 Thread Geir Hauge
On Sat, Oct 10, 2015 at 08:01:05PM -0700, Linda Walsh wrote: > # this is odd: 2vars with content for 2: > >unset a b > >a= b= read a b <<< x y > >declare -p a b > declare -- a="x" > declare -- b="" > > # -- where did "y" go? read a b <<< x y is the same as read a b y <<< x If you escap

Re: bash displays strange characters after base64 decoding

2015-08-07 Thread Geir Hauge
it about this fun feature here: http://www.in-ulm.de/~mascheck/various/alternate_charset/ -- Geir Hauge

Re: substitution "read all from fd" silently fails: $(<

2015-07-01 Thread Geir Hauge
On Wed, Jul 01, 2015 at 10:19:10PM +0300, Ilya Basin wrote: > Hi list. > > Want to read whole stdin into variable. > Don't want to spawn new processes (cat). > Don't want to reopen existing fd &0 > > First thing I tried: $(<&0) > It silently returns an empty string. This type of query is prefera

Re: unset does not act as expected on namerefs

2015-05-26 Thread Geir Hauge
> 'var'. > dualbus@hp:~$ unset ref; ref=var; echo "$ref"; declare -p ref > var > declare -n ref="var" > dualbus@hp:~$ declare -p var > declare -- var="var" Ah, that explains it! Mystery solved, and no longer surprising behavior. -- Geir Hauge

Re: unset does not act as expected on namerefs

2015-05-26 Thread Geir Hauge
but a "wow, this > is surprising - maybe this could behave in a manner so it's not so > surprising". The surprising part is that it keeps the -n flag, but partially loses the nameref ability: $ var=foo; declare -n ref $ ref=var $ printf '%s - ' "$ref"; declare -p ref foo - declare -n ref="var" $ unset ref $ ref=var $ printf '%s - ' "$ref"; declare -p ref var - declare -n ref="var" $ ref=baz baz - declare -n ref="var" -- Geir Hauge

mapfile segfaults when unsetting array in callback

2015-03-25 Thread Geir Hauge
64-unknown-linux-gnu Bash Version: 4.3 Patch Level: 33 Release Status: release Description: When using mapfile's callback feature, and the callback unsets the array mapfile is appending to, it segfaults. Repeat-By: callback() { unset MAPFILE; } (mapfile -c 1 -C callback <<< x) -- Geir Hauge

Re: Does [ -f FILE ] have a bug on testing a symlink ?

2015-02-09 Thread Geir Hauge
bash/manual/bashref.html#Bash-Conditional-Expressions Probably wouldn't hurt to include that in the help text for the test builtin as well. -- Geir Hauge

Re: BASH_FUNC__ appearing in environment

2014-11-28 Thread Geir Hauge
lare -xf _rcs'' 2. you happen to run ''set -a'' at some point before the completion function gets dynamically loaded. When ''set -a'' is in effect, all variables and functions you define get automatically exported. If the output of ''echo "$-"'' contains 'a', then it is in effect. -- Geir Hauge

Re: feature: time builtin and file descriptor

2014-10-31 Thread Geir Hauge
c took 3.001 seconds all together took: 9.004 seconds It would be prettier if TIMEFORMAT could be set on invocation of time, e.g. TIMEFORMAT='foo took %R seconds' time { ...; } , but time being a keyword probably makes that hard. One also has to be careful to sanitize any variables one embeds in TIMEFORMAT since % characters are special. -- Geir Hauge

Re: Issue with Bash-4.3 Official Patch 27

2014-10-16 Thread Geir Hauge
invalid identifiers? It doesn't at present: $ env %=% bash -c 'echo "$BASH_VERSION"; source <(declare -xp)' 4.3.30(1)-release /dev/fd/63: line 1: declare: `%': not a valid identifier Isn't declare -p output meant to be reusable as shell input? -- Geir Hauge

Re: Issues with exported functions

2014-09-25 Thread Geir Hauge
fault; it violates the "don't treat data as code" rule. Sure would be nice if there was a separate flag that only disables parsing of exported functions. -- Geir Hauge

Re: Issues with exported functions

2014-09-25 Thread Geir Hauge
> new syntax in 4.3? > > (still in 4.2.43 here)... Bash has had this feature since "forever" $ fun='() { echo "$BASH_VERSION";}' bash1 -c fun 1.14.7(1) Your bash 4.2.43 is no exception, but the way declare's -p and -f options interact did change in 4.3, so try with just ''declare -f fun'' instead -- Geir Hauge

Re: Segmentation fault bash 4.3.022

2014-08-11 Thread Geir Hauge
true | false; }' 4.3.22(1)-release xxSegmentation fault And lastly, in interactive mode $ set +m; shopt -s lastpipe; trap -- "printf x" ERR; true | { true | false; } xxx Can't quite understand why it would trigger the ERR trap thrice. -- Geir Hauge

Re: sourcing script file from inside a function doesn't work anymore

2014-05-12 Thread Geir Hauge
='(x)'; declare -p array; declare -p | grep array= \n"); }; f bash: declare: array: not found declare -a array='([0]="x")' Oddly, the quotes seem to matter; changing array='(x)' to array=(x) makes it work... $ f() { source <(printf "declare -a array=(x); declare -p array\n"); }; f declare -a array='([0]="x")' -- Geir Hauge

Re: ${assoc[key]+set} no longer works.

2014-03-19 Thread Geir Hauge
anks. That patch also makes [[ -v assoc[x] ]] return 0. However, [[ -v assoc ]] returns 1 (which it also does before the patch). Sounds related to this bug. -- Geir Hauge

${assoc[key]+set} no longer works.

2014-03-18 Thread geir . hauge
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-unknown-linux-gnu' -DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/local/share

Re: read builtin is not honoring -t argument

2013-12-12 Thread Geir Hauge
ad'' say? perhaps you have a function or alias by that name. I can't reproduce it either. -- Geir Hauge

Re: The default value of TIMEFORMAT is incorrectly formatted

2013-11-02 Thread Geir Hauge
uld be $'\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS'. > > Thanks for the report. This has already been fixed for bash-4.3. > I reported this a while back too, and it is changed in the latest devel branch, but it appears you introduced a different typo: $'\nreal\t%3lR\nuser\t%3lU\nsys\tt%3lS' -- Geir Hauge

Re: && operator prevents backgrounding over ssh

2013-09-26 Thread Geir Hauge
nohup sleep 10 >/dev/null 2>&1; } & so the backgrounded process still have stdout and stderr connected to ssh. This should do what you want: cd /tmp && { nohup sleep 10 >/dev/null 2>&2 & } -- Geir Hauge

Re: Inaccurate modification date testing

2013-08-14 Thread Geir Hauge
2013/8/14 Jacek Krüger > Bash is innacurate when testing modification dates. It ignores fractions > of a second. Is it expected? Coreutils test does it properly. > Looks like that is fixed in 4.3-alpha http://git.savannah.gnu.org/cgit/bash.git/tree/CHANGES?h=devel#n554 -- Geir Hauge

Typos and other issues with the documentation

2013-08-05 Thread Geir Hauge
ated into the above msgstr. So I suggest avoiding translating the empty string. I'm attaching patches against the latest git devel branch for the above five typos/bugs/suggestions. -- Geir Hauge 0001-wait-n.patch Description: Binary data 0002-help-hash-use-PATHNAME-is-the-ful

Invalid extglob causes segfault with help builtin.

2013-08-05 Thread Geir Hauge
egfault. This also happens in bash 4.2.45 and 4.2.25, but not 3.2.48. It only segfaults when extglob is enabled; probably because it's an incomplete extglob. Repeat-By: bash -O extglob -c 'help "*((*"' -- Geir Hauge

Re: Another "set" option?

2013-07-10 Thread Geir Hauge
t; xtrace_setting=$(set -q xtrace) or something. Could we get > something fairly straight forward for querying set/shopt state? > Thank you for considering. Regards, Bruce > shopt -qo xtrace && xtrace=1 -- Geir Hauge

Re: PS1 multiline with colors

2013-07-09 Thread Geir Hauge
ext release though. http://lists.gnu.org/archive/html/bug-bash/2012-09/msg6.html -- Geir Hauge

Loadables fail to build in devel branch

2013-05-25 Thread Geir Hauge
The code for the cut and getconf loadables under examples/loadables has apparently been removed, but the Makefile hasn't been updated accordingly. See attached patch. -- Geir Hauge removed_loadables.patch Description: Binary data

Re: Redirect a backgrounded process' stdout toward COPROC's stdin

2012-06-03 Thread Geir Hauge
rather this one (ampersand > moved before redirection): > >    #!/bin/bash >    # TEST 2 >    coproc /bin/sleep 100 >    echo & >&${COPROC[1]} This is equivalent to echo & >&${COPROC[1]} & ends the command, so the redirection is not applied to the echo. See http://wiki.bash-hackers.org/syntax/keywords/coproc -- Geir Hauge

Re: handling of test == by BASH's POSIX mode

2012-05-27 Thread Geir Hauge
is. Don't use non-POSIX features in a POSIX script, and you'll be fine. http://www.opengroup.org/onlinepubs/9699919799/utilities/contents.html -- Geir Hauge

Re: compgen is slow for large numbers of options

2012-03-19 Thread Geir Hauge
.) Letting compgen do the command substitution speeds it up considerably $ TIMEFORMAT=%R $ time compgen -W "`seq 1 50`" 1794 >/dev/null 175.253 $ time compgen -W '`seq 1 50`' 1794 >/dev/null 2.347 -- Geir Hauge

Re: TAB vs. colon

2011-12-30 Thread Geir Hauge
tead of ls u do ls ''u -- Geir Hauge

Re: '>;' redirection operator [was: [1003.1(2008)/Issue 7 0000530]: Support in-place editing in sed (-iEXTENSION)]

2011-12-22 Thread Geir Hauge
t file > file.tmp && mv file.tmp file I'd welcome this >; syntax. -- Geir Hauge

Re: exit status issue

2011-11-18 Thread Geir Hauge
2011/11/17 Dallas Clement > > Would appreciate any insight you could offer. Here is my script and > the strace output for when touch returns 1. > Add ''set -x'' at the start of the function and examine the output to see if it actually runs touch from PATH. -- Geir Hauge

Re: invoke tilde expansion on quoted string

2011-11-12 Thread Geir Hauge
;> > > eval "cd $var" > I'd avoid eval as that could potentially do more than just expand the tilde, depending on what other characters the var contains. I'd just replace the ~ with $HOME using parameter expansion. cd "${var/#~\//$HOME/}" -- Geir Hauge

Re: bug? {1..3} doesnt' use IFS to separate fields

2011-07-27 Thread Geir Hauge
separate arguments? > I don't see the usefulness in having brace expansion's behavior changed by IFS. If you want {1..3} to turn into the string "1;2;3", assign it to an array, then print the array that way array=( {1..3} ) (IFS=';'; echo "${array[*]}") # outputs "1;2;3" printf -v var '%s;' "${array[@]}"; echo "$var" # outputs "1;2;3;" -- Geir Hauge