Re: RFE: new option affecting * expansion

2021-08-11 Thread Chris F.A. Johnson
On Wed, 11 Aug 2021, Chet Ramey wrote: On 8/10/21 5:08 PM, Chris F.A. Johnson wrote: It would be nice if there were an option to allow * to expand sorted by timestamp rather than aphabetically. When you say `timestamp' I assume you mean by last modification time. Yes, that's what I meant

RFE: new option affecting * expansion

2021-08-10 Thread Chris F.A. Johnson
It would be nice if there were an option to allow * to expand sorted by timestamp rather than aphabetically. -- Chris F.A. Johnson <http://cfajohnson.com/> === Author: === Shell Scripting Recipes: A P

Re: Extended regex match (shmatch.c:115) malloc error

2021-08-09 Thread Chris F.A. Johnson
r Aborting...ABORT instruction (core dumped) -- I get: '123' in '123 text!' (bash 5.1 in mate-terminal) -- Chris F.A. Johnson <http://cfajohnson.com/>

Re: Redirection between assignment statement and command name prevents alias substitution

2021-03-25 Thread Chris F.A. Johnson
(which I do for all interactive uses) because that would change $FUNCNAME. -- Chris F.A. Johnson <http://cfajohnson.com/> === Author: === Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) Pro B

Re: Feature: where terminal reports mouse click to bash, support positioning the cursor accordingly

2021-01-17 Thread Chris F.A. Johnson
use button to position the cursor. https://cfajohnson.com/shell/?2005-07-15_mousetraps -- Chris F.A. Johnson <http://cfajohnson.com/> === Author: === Shell Scripting Recipes: A Problem-Solution Approa

Re: Preventing Bash Variable Confusion

2020-01-30 Thread Chris F.A. Johnson
style definition macros. Variables become extremely identifiable and comprehensible. A text editor, such as emacs in Bash mode, can highlight variables. No need to use any sort of naming convention. -- Chris F.A. Johnson <http://cfajohnson.

Re: Preventing Bash Variable Confusion

2020-01-30 Thread Chris F.A. Johnson
tegar only.) This is just wrong. `local' accepts the same option set as `declare'. There are other things wrong in that book as well; the description of printf, for example. Don't use it as an authority on bash. -- Chris F.A. Johnson <http://c

Re: Preventing Bash Variable Confusion

2020-01-29 Thread Chris F.A. Johnson
On Wed, 29 Jan 2020, Greg Wooledge wrote: As long as you use at least one lowercase letter in your variable name, you are guaranteed not to conflict with any internal shell variables. Except for auto_resume and histchars. -- Chris F.A. Johnson <h

Re: man bash does not list 'in' as a builtin command

2019-11-25 Thread Chris F.A. Johnson
page as such. $ type in in is a shell keyword -- Chris F.A. Johnson <http://cfajohnson.com/> === Author: === Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) Pro Bash Progr

Re: $"\t': Bash bug or not?

2017-11-17 Thread Chris F.A. Johnson
installed. -- Chris F.A. Johnson, <http://cfajohnson.com>

Re: consistency probs var & function re-use

2017-06-09 Thread Chris F.A. Johnson
On Fri, 9 Jun 2017, L A Walsh wrote: Chris F.A. Johnson wrote: On Fri, 9 Jun 2017, L A Walsh wrote: First problem: If you are assigning a string to a variable, you need to put quotes around the string. You don't need to quote it unless it contains literal whitespace. Not exactly

Re: consistency probs var & function re-use

2017-06-09 Thread Chris F.A. Johnson
On Fri, 9 Jun 2017, L A Walsh wrote: Chris F.A. Johnson wrote: On Fri, 9 Jun 2017, L A Walsh wrote: First problem: If you are assigning a string to a variable, you need to put quotes around the string. You don't need to quote it unless it contains literal whitespace. Not exactly

Re: consistency probs var & function re-use

2017-06-09 Thread Chris F.A. Johnson
On Fri, 9 Jun 2017, L A Walsh wrote: First problem: If you are assigning a string to a variable, you need to put quotes around the string. You don't need to quote it unless it contains literal whitespace. -- Chris F.A. Johnson, <http://cfajohnson.com>

Re: weird error due to cntrl-c out of history list

2017-02-20 Thread Chris F.A. Johnson
call -- Chris F.A. Johnson, <http://cfajohnson.com>

Re: 'cat' and 'rm' as builtins ?

2016-10-30 Thread Chris F.A. Johnson
On Sun, 30 Oct 2016, Tim Rühsen wrote: ... Since cat and rm implementations are pretty small in code size, I wonder if you (the maintainers) would accept patches to make these commands builtin commands. Have you looked at the loadable builtins in the examples directory? -- Chris F.A

Re: Bash-4.4-beta2 available for download

2016-07-13 Thread Chris F.A. Johnson
On Wed, 13 Jul 2016, Chet Ramey wrote: On 7/13/16 10:58 AM, Chet Ramey wrote: On 7/13/16 10:49 AM, Chris F.A. Johnson wrote: On Tue, 12 Jul 2016, Chet Ramey wrote: The second beta release of bash-4.4 is now available with the URL ftp://ftp.cwru.edu/pub/bash/bash-4.4-beta2.tar.gz I get

Re: Bash-4.4-beta2 available for download

2016-07-13 Thread Chris F.A. Johnson
=> TYPE I ... done. ==> CWD (1) /pub/bash ... done. ==> SIZE bash-4.4-beta2.tar.gz ... 8932859 ==> PASV ... -- Chris F.A. Johnson, <http://cfajohnson.com>

Re: Bash logo

2015-12-16 Thread Chris F.A. Johnson
with the proposed new logo designs where you can vote for your favorite: http://goo.gl/forms/qjohwvtgys I chose no. 2, but I would like it better with the colours reversed. -- Chris F.A. Johnson, <http://cfajohnson.com>

Re: why must bash zap last search string just because we hit ^C?

2015-10-17 Thread Chris F.A. Johnson
essary) and RET. -- Chris F.A. Johnson, <http://cfajohnson.com>

Re: why must bash zap last search string just because we hit ^C?

2015-10-17 Thread Chris F.A. Johnson
On Sun, 18 Oct 2015, 積丹尼 Dan Jacobson wrote: "CFAJ" == Chris F A Johnson <ch...@cfajohnson.com> writes: CFAJ> Or just press UP (as many times as necessary) and RET. That won't get me to a $ prompt. I want to suspend my search and resume it later. ^Z then fg -- Chris

Re: Design question(s), re: why use of tmp-files or named-pipes(/dev/fd/N) instead of plain pipes?

2015-10-17 Thread Chris F.A. Johnson
a usage where it expands to a filename and is treated as such. Try this: echo <(cat /etc/passwd) -- Chris F.A. Johnson, <http://cfajohnson.com>

Re: coredump with wait -n

2015-08-22 Thread Chris F.A. Johnson
with multiple jobs. $ bash --norc bash-4.3$ sleep 1 sleep 2 wait -n [1] 8368 [2] 8369 [1]- Donesleep 1 bash-4.3$ ^C*** stack smashing detected ***: bash terminated I have no problem running that line, and ^C still works. -- Chris F.A. Johnson, http://cfajohnson.com

Re: No support for spaces in for loop

2015-08-18 Thread Chris F.A. Johnson
of duck.jpg will be interpreted as 4 files an image of duck.jpg Yes, it does. Your problem is (probably, since you didn't include an example) that you omitted quotes around its expansion, e.g.: printf '%s\n' $file That should be: printf '%s\n' $file Repeat-By: -- Chris F.A. Johnson

Re: BUG?: (or what's going on?) test for NL == NL fails (bash-4.3.39(3)-release)

2015-08-02 Thread Chris F.A. Johnson
$nl '$1 ; } ord $(printf \n) Trailing newline are stripped from command substitution, making $(printf \n) and empty string. If you want a newline, use: ord $'\n' -- Chris F.A. Johnson, http://cfajohnson.com

Re: Problem with brace expansion

2015-04-21 Thread Chris F.A. Johnson
dash handle either case correctly: Neither pdksh nor dash has brace expansion. -- Chris F.A. Johnson, http://cfajohnson.com

Re: Should nested case statements within command substitutions work on in bash 3.2.x?

2015-03-22 Thread Chris F.A. Johnson
in yes) echo yes; ;; no) echo no; ;; esac)' It does work with bash 4.x. Is this a known issue with 3.2 or is it particular to the OSX implementation (which in my case is 3.2.53(1))? Balance the parentheses: echo $(case yes in (yes) echo yes; ;; (no) echo no; ;; esac) -- Chris F.A. Johnson

Re: Bash-4.3 Official Patch 25

2014-09-24 Thread Chris F.A. Johnson
://ftp.cwru.edu/pub/bash site just has the main 4.3 file and 25 separate patches to merge. A downloadable tar file of the current version with all official patches applied is available from savannah. http://git.savannah.gnu.org/cgit/bash.git/snapshot/bash-master.tar.gz -- Chris F.A. Johnson

Re: Substring Expansion does not work as intended

2014-08-20 Thread Chris F.A. Johnson
a variable: o=-2 echo ${x:$o} -- Chris F.A. Johnson, http://cfajohnson.com

Re: read-only flag is lost for functions in sub shells

2014-07-31 Thread Chris F.A. Johnson
readonly ${rov[@]} fi foo=q ## not permitted -- Chris F.A. Johnson, http://cfajohnson.com

Re: umask --help

2014-07-07 Thread Chris F.A. Johnson
On Mon, 7 Jul 2014, Notes Jonny wrote: ... Would you consider adding a --help option for umask please? (I understand this is a built in command) Maybe also --version I was just hoping to find some help for it. info umask and man umask also don't say anything. help umask

Re: odd behavior from overloading the source builtin

2014-03-16 Thread Chris F.A. Johnson
On Sun, 16 Mar 2014, Doug McIlroy wrote: GNU bash, version 4.2.39(1)-release (x86_64-redhat-linux-gnu) interprets this shell script differently when bash input comes from a terminal or when it conmes from a file: source(){ echo x } source In the former case it

Re: continuously evaluated prompts/environmental variables

2013-11-26 Thread Chris F.A. Johnson
`' -- Chris F.A. Johnson, http://cfajohnson.com

Re: How to create bash-pattern to exclude a matching param in param expansionmatching?

2013-10-28 Thread Chris F.A. Johnson
in functionality. I.e.: ls !($(echo *+(-IGN-)*|tr |)) I tried the above in a dir that has 2 files w/the pattern, and 532 w/o, and it worked, but how much of that was 'luck'? Is there a better bash-pattern that doesn't use tr and such? ls !(*-IGN-*) -- Chris F.A. Johnson, http://cfajohnson.com/

Re: i++ cause bad return code when result is 1

2013-08-26 Thread Chris F.A. Johnson
, that it is != 0 Compare: $ (( 0 )); echo $? 1 $ (( 1 )); echo $? 0 $ (( -1 )); echo $? 0 -- Chris F.A. Johnson, http://cfajohnson.com/ Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: ldapscripts unusable from within a 'while read line' loop

2013-08-01 Thread Chris F.A. Johnson
is or does (I can't find it for my system), but perhaps it reads from stdin? If it does, it will be reading from the file. -- Chris F.A. Johnson, http://cfajohnson.com/ Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem

Re: currently doable? Indirect notation used w/a hash

2013-06-10 Thread Chris F.A. Johnson
entirely. It is not the least bit difficult with eval: eval array=( \\${$1[@]}\ ) -- Chris F.A. Johnson, http://cfajohnson.com/ Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: currently doable? Indirect notation used w/a hash

2013-06-10 Thread Chris F.A. Johnson
On Mon, 10 Jun 2013, Chris Down wrote: Enjoy your arbitrary command execution. Can you give me an example, using the code I posted, where that would happen? On 10 Jun 2013 14:15, Chris F.A. Johnson ch...@cfajohnson.com wrote: On Mon, 10 Jun 2013, Greg Wooledge wrote: On Sun, Jun 09

Re: currently doable? Indirect notation used w/a hash

2013-06-10 Thread Chris F.A. Johnson
On Mon, 10 Jun 2013, Greg Wooledge wrote: On 10 Jun 2013 14:15, Chris F.A. Johnson ch...@cfajohnson.com wrote: It is not the least bit difficult with eval: eval array=( \\${$1[@]}\ ) On Mon, Jun 10, 2013 at 09:17:23PM +0800, Chris Down wrote: Enjoy your arbitrary command execution

Re: `declare -fp` mishandles heredoc with || statement

2013-05-31 Thread Chris F.A. Johnson
of bash i tried fails this way (2.05b through 4.2.45) With 4.2.37: func () { cat / EOF || 11 EOF echo FAIL } -- Chris F.A. Johnson, http://cfajohnson.com/ Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem-Solution

Re: Interpretation of escapes in expansions in pattern matching contexts

2013-04-06 Thread Chris F.A. Johnson
no But not in ksh93: $ x=\\x; if [[ x == $x ]]; then echo yes; else echo no; fi no $ x=\\x; if [ x == $x ]; then echo yes; else echo no; fi no -- Chris F.A. Johnson, http://cfajohnson.com/ Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem

Re: Local variables overriding global constants

2013-04-03 Thread Chris F.A. Johnson
are local to a function and don't exist outside their own functions. -- Chris F.A. Johnson, http://cfajohnson.com/ Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: Local variables overriding global constants

2013-04-03 Thread Chris F.A. Johnson
On Wed, 3 Apr 2013, Nikolai Kondrashov wrote: On 04/03/2013 10:53 AM, Chris Down wrote: On 2013-04-03 10:50, Nikolai Kondrashov wrote: On 04/03/2013 10:43 AM, Chris F.A. Johnson wrote: On Wed, 3 Apr 2013, Nikolai Kondrashov wrote: I.e. this: bash -c 'declare -r v; a() { declare -r v

Re: Local variables overriding global constants

2013-04-03 Thread Chris F.A. Johnson
F.A. Johnson, http://cfajohnson.com/ Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: Local variables overriding global constants

2013-04-03 Thread Chris F.A. Johnson
On Wed, 3 Apr 2013, Pierre Gaston wrote: On Wed, Apr 3, 2013 at 11:33 AM, Chris F.A. Johnson ch...@cfajohnson.comwrote: On Wed, 3 Apr 2013, Pierre Gaston wrote: On Wed, Apr 3, 2013 at 11:03 AM, Chris Down ch...@chrisdown.name wrote: On 2013-04-03 11:00, Nikolai Kondrashov wrote

Re: Bug/limitation in 'time'

2013-03-16 Thread Chris F.A. Johnson
On Sun, 17 Mar 2013, William Park wrote: On Sat, Mar 16, 2013 at 10:15:50PM -0400, Chris F.A. Johnson wrote: On Sun, 17 Mar 2013, Chris Down wrote: ExprCount() { for (( i = $1 ; i 0 ; i-- )); do : done echo $1 iterations } Or, in a POSIX-compliant manner

Re: More fun with IFS

2013-01-30 Thread Chris F.A. Johnson
On Wed, 30 Jan 2013, Andreas Schwab wrote: Chris F.A. Johnson ch...@cfajohnson.com writes: var=${a[*]} ... one two three four # bad Looks good to me. It expands to multiple words, just as an unquoted $* would do. But no field splitting is performed on the expansion, so why

Re: More fun with IFS

2013-01-29 Thread Chris F.A. Johnson
three:::four for the last 4, which I think is correct. -- Chris F.A. Johnson, http://cfajohnson.com/ Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: fd leak with {fd}

2012-11-26 Thread Chris F.A. Johnson
On Mon, 26 Nov 2012, Chet Ramey wrote: ,,, There have been unsuccessful new features -- the case-modifying expansions are one example of a swing and miss. A miss? I use them a lot. -- Chris F.A. Johnson, http://cfajohnson.com/ Author: Pro Bash Programming: Scripting the GNU/Linux

RFE: read -d STRING

2012-11-23 Thread Chris F.A. Johnson
I would find it very useful to allow a string of delimiters to be used with 'read -d', with any member of the string terminating the input and the character used being stored in a variable, e.g. READ_DELIM. -- Chris F.A. Johnson, http://cfajohnson.com/ Author: Pro Bash

Re: Parsing error when case in for in $()

2012-09-11 Thread Chris F.A. Johnson
is being interpreted as the closing for $( Fix: Probably by fixing the bash parser. Balance the parentheses in the case statement: echo $(for x in whatever; do case y in (*) echo 42;; esac; done) -- Chris F.A. Johnson, http://cfajohnson.com/ Author: Pro Bash Programming: Scripting

Re: Double quoted history expansion character cannot be escaped

2012-08-06 Thread Chris F.A. Johnson
: histchars= -- Chris F.A. Johnson, http://cfajohnson.com/ Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: why must non-standard $IFS members be treated so differently ?

2012-07-29 Thread Chris F.A. Johnson
=($@); echo ${#v[@]}; } Always quote $@. Without quotes, it's the same as $* function count_args {v=( $@ ); echo ${#v[@]}; } -- Chris F.A. Johnson, http://cfajohnson.com/ Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting

Re: locale specific ordering in EN_US -- why is aAbByYzZ?

2012-05-21 Thread Chris F.A. Johnson
=C in your scripts. My OS uses en_US.UTF-8. My OS uses whatever I tell it to (which is C). You'd think unicode would have something to say about collation order that wouldn't allow such randomness, but maybe not. -- Chris F.A. Johnson, http://cfajohnson.com/ Author: Pro Bash

Re: status on $[arith] for eval arith vsl $((arith))??

2012-04-08 Thread Chris F.A. Johnson
to it -- yet it works, and old code seems to rely on it -- and $[(1+2)/3] looks cleaner than $(((1+2)/3)). So what's up with that? At the minor expense of a few extra keystrokes, $(( (1+2) / 3 )) looks just as clean, and has the added cachet of being portable. -- Chris F.A. Johnson, http

Re: test if shell is interactive

2012-01-22 Thread Chris F.A. Johnson
: if [ -t 1 ] then echo Interactive else echo Not interactive fi -- Chris F.A. Johnson, http://cfajohnson.com/ Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: bash 3.2 vs 3.0

2012-01-05 Thread Chris F.A. Johnson
On Thu, 5 Jan 2012, Dave wrote: Hi all, Recently upgraded to 3.2 and noticed some differences in a lot of my scripts, consider the following example: ... Could anyone point me in correct direction on this one ? Upgrade to 4.2; you are years behind the times! -- Chris F.A. Johnson

Re: converting array to string by quoting each element for eval

2011-11-15 Thread Chris F.A. Johnson
string is almost always the wrong way to go about it. -- Chris F.A. Johnson, http://cfajohnson.com/ Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: converting array to string by quoting each element for eval

2011-11-15 Thread Chris F.A. Johnson
$ ./not_convert_args_to_string.sh . -type f -name '*' find: `./cvcd': Permission denied find . -type f -name '*' Use 'set -x' to see exactly what your script is doing. -- Chris F.A. Johnson, http://cfajohnson.com/ Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell

Re: Questions about commandline-args

2011-11-11 Thread Chris F.A. Johnson
it: personal_function ab{c,d} -- Chris F.A. Johnson, http://cfajohnson.com/ Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: Questions about commandline-args

2011-11-11 Thread Chris F.A. Johnson
On Sat, 12 Nov 2011, Christopher Roy Bratusek wrote: On Friday 11 November 2011 19:32:51 Chris F.A. Johnson wrote: On Fri, 11 Nov 2011, Christopher Roy Bratusek wrote: Hi list, I've got a question about commandline args, imagine: personal_function ab{c,d} personal_function will receive abc

Re: invoke tilde expansion on quoted string

2011-11-11 Thread Chris F.A. Johnson
expansion on it. var='~/..' cd $var#how to change this line? eval cd $var -- Chris F.A. Johnson, http://cfajohnson.com/ Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: bash-completion between do and done

2011-11-05 Thread Chris F.A. Johnson
version of bash? I can confirm it on 3.05b, 3.0 and 4.2: while [ ${n:=0} -lt 5 ] do seTAB All I get is a beep. -- Chris F.A. Johnson, http://cfajohnson.com/ Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem-Solution

Re: Another mapfile question.

2011-08-06 Thread Chris F.A. Johnson
change it back within a function: foo() { local IFS=bar : whatever } The original value is not changed in the calling script. -- Chris F.A. Johnson http://cfaj.freeshell.org === Author: Shell

Re: awk or sed

2011-04-05 Thread Chris F.A. Johnson
if anybody have experience with them or any other means to do it. printf %s\n $var1 (You might want to precede that with 'set -f'.) -- Chris F.A. Johnson, http://cfajohnson.com/ Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem

Re: BASH_SUBSHELL documentation misleading

2011-03-23 Thread Chris F.A. Johnson
that: echo $BASH_SUBSHELL ; ( echo $BASH_SUBSHELL ) would not give the same answer for BASH_SUBSHELL In your example, the second echo $BASH_SUBSHELL is at the same depth as the first. -- Chris F.A. Johnson, http://cfajohnson.com/ Author: Pro Bash Programming: Scripting the GNU/Linux

Negative array subscript with unset

2011-03-12 Thread Chris F.A. Johnson
I all versions I have tried, unsetting an array element using a negative index fails: $ array=( q w e r t y ) $ unset 'array[-1]' bash: [-1]: bad array subscript -- Chris F.A. Johnson, http://cfajohnson.com/ Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009

Re: case modification won't work with pattern

2011-03-10 Thread Chris F.A. Johnson
^[a-m]} ## Convert first character that matches pattern Bar $ echo ${foo^^[a-m]} ## Convert all characters that match pattern BAr -- Chris F.A. Johnson, http://cfajohnson.com/ Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem

Re: multi-line commands in the history get split when bash is quit

2011-02-05 Thread Chris F.A. Johnson
to the history file so they may be preserved across shell sessions. However this is not done in any version of bash that I can find. -- Chris F.A. Johnson, http://cfajohnson.com/ Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell

Re: 'help set' missing '--'

2011-01-10 Thread Chris F.A. Johnson
On Mon, 10 Jan 2011, Jan Schampera wrote: the help output for the set builtin command misses '--'. It's there: SYNOPSIS set [--abefhkmnptuvxBCHP] [-o option-name] [arg ...] -- Chris F.A. Johnson, http://cfajohnson.com Author: Pro Bash Programming: Scripting the GNU/Linux

Re: 'help set' missing '--'

2011-01-10 Thread Chris F.A. Johnson
On Mon, 10 Jan 2011, Christopher Roy Bratusek wrote: On Monday 10 January 2011 09:06:42 Chris F.A. Johnson wrote: On Mon, 10 Jan 2011, Jan Schampera wrote: the help output for the set builtin command misses '--'. It's there: SYNOPSIS set [--abefhkmnptuvxBCHP] [-o option-name] [arg

Re: cd with multiple arguments?

2010-12-14 Thread Chris F.A. Johnson
. -- Chris F.A. Johnson, http://cfajohnson.com Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: Clear Screen

2010-12-01 Thread Chris F.A. Johnson
at the options to xterm (man xterm). (There may not be an option that does what you want.) -- Chris F.A. Johnson, http://cfajohnson.com Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: IFS=':' set -- aa:bb:cc:dd # Fails to set $@

2010-12-01 Thread Chris F.A. Johnson
. Fix: Offered in the constructive spirit to see if this needs to be fixed or if this is a deliberate or known behavior. That is the way it should behave. The line is parsed before IFS is set. -- Chris F.A. Johnson, http://cfajohnson.com Author: Pro Bash Programming

Re: ionice bash pid in bash_profile Fails

2010-11-22 Thread Chris F.A. Johnson
of the shell. The following works like a charm: # See ionice manfile - give high priority to Bash ionice -c 2 -n 0 -p `echo $$` Why are you using echo? ionice -c 2 -n 0 -p $$ -- Chris F.A. Johnson, http://cfajohnson.com Author: Pro Bash Programming: Scripting the GNU/Linux Shell

Re: associative array assignment from the output of a function

2010-10-22 Thread Chris F.A. Johnson
-asus plugins]$ declare -A foo=( $(func) ) $ declare -A foo=('[a]=5') Drop the qotes: declare -A foo=( [a]=5 ) bash: foo: [a]=5: must use subscript when assigning associative array $ eval declare -A foo=($(echo '[a]=5')); echo ${foo[a]} 5 -- Chris F.A. Johnson, http://cfajohnson.com

Re: bash auto complete malloc 'assertion botched' error

2010-10-09 Thread Chris F.A. Johnson
differ Aborting... Repeat-By: typing cd '\ or ls \ will reproduce the above bug Using: GNU bash, version 4.1.7(2)-release (amd64-portbld-freebsd8.1) does not seem to produce that error. Nor does 4.0.28(2)-release on Mandriva 2009.1. -- Chris F.A. Johnson, http://cfajohnson.com

Re: asking for a better way to implement this

2010-09-27 Thread Chris F.A. Johnson
might put it in a script, expecting to be prompted, and lose files you need. Aliases are not expanded in a script. -- Chris F.A. Johnson, http://cfajohnson.com Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem-Solution

Re: asking for a better way to implement this

2010-09-26 Thread Chris F.A. Johnson
On Sun, 26 Sep 2010, Christopher Roy Bratusek wrote: btw. How can I remove the last arguement ${!#} ? I tried args=${@:-${!#}} but that won't work. args=( $@ ) unset args[$#-1] set -- ${ar...@]} -- Chris F.A. Johnson, http://cfajohnson.com Author: Pro Bash Programming: Scripting

Re: How to deal with space in command line?

2010-09-18 Thread Chris F.A. Johnson
characters such as space by adding '\' in front them? This will supply as many files as possible as arguments to stat: find . -type f -exec stat --printf %y %n\n + -- Chris F.A. Johnson, http://cfajohnson.com Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress

Re: Bash style of if-then-else?

2010-08-24 Thread Chris F.A. Johnson
advantage over standard syntax. [[ ... ]] is not standard, and offers little over the standard syntax. -- Chris F.A. Johnson, http://cfajohnson.com Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem-Solution Approach

Re: Issues when func name is the same with an alias

2010-08-05 Thread Chris F.A. Johnson
. -- Chris F.A. Johnson, http://cfajohnson.com Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: RFE -or- Howto?

2010-08-03 Thread Chris F.A. Johnson
is negligible compared to portability. It makes it clear that you are no longer doing what I want, a multi-variable assignment. It *is* a multi-variable assignment. But that's my sense of what looks readable in codeYMMV. On 8/2/2010 3:51 PM, Chris F.A. Johnson wrote: On Mon, 2

Re: basic pattern match Question...newbie doesn't understand (!...@#$@$)

2010-08-01 Thread Chris F.A. Johnson
like such a basic concept. Sorry, this newbie needs help on such trivial matters. :-( When quoted, the right-hand argument is matched as a string, not an expression. -- Chris F.A. Johnson, http://cfajohnson.com Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009

Re: Naming convention of bash script filenames

2010-07-11 Thread Chris F.A. Johnson
for this are in the last chapter of my first book, Shell Scripting Recipes.) -- Chris F.A. Johnson, http://cfajohnson.com Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: Bash cannot kill itself?

2010-06-30 Thread Chris F.A. Johnson
of the parent (main) shell you use. Then what's the problem with my script in my original mail? Seems like Bash does not handle the signal in a real-time way. The special variable $$ refers to the current process, even if it has the same numeric value as the parent script. -- Chris F.A

Re: Bash cannot kill itself?

2010-06-29 Thread Chris F.A. Johnson
On Wed, 30 Jun 2010, Clark J. Wang wrote: On Wed, Jun 30, 2010 at 12:38 PM, Chris F.A. Johnson ch...@cfajohnson.comwrote: On Wed, 30 Jun 2010, Clark J. Wang wrote: I have a bash script like this: #!/bin/bash trap 'echo killed by SIGALRM; exit 1' ALRM function

Re: How to supply a string with space in it as parameter to a function?

2010-06-23 Thread Chris F.A. Johnson
e f g -- Chris F.A. Johnson, http://cfajohnson.com Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: Question if bug: declaration of an associative array within a function

2010-06-15 Thread Chris F.A. Johnson
from 'declare' being a duplicate of the (non-standard) typeset builtin. If would be much more useful (and semantically accurate), if it just did what its name implies, and left the 'local' builtin for declaring variable local to a function. -- Chris F.A. Johnson, http://cfajohnson.com

Re: How to autocomplete after 'which'?

2010-05-21 Thread Chris F.A. Johnson
. Since pwd is a shell command, when /bin/pwd is actually used? In shells that don't have built-in pwd? And all POSIX shells have the $PWD variable. -- Chris F.A. Johnson, http://cfajohnson.com Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell

Re: How to make a directory name with '/' in it?

2010-05-16 Thread Chris F.A. Johnson
name: / and NUL. -- Chris F.A. Johnson, http://cfajohnson.com Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: Help with sed

2010-04-17 Thread Chris F.A. Johnson
'/mandriva/,/fi;}/p'); content=$(echo $content | sed '/^\s*urpmi[:space:]--auto/p'); -- Chris F.A. Johnson, http://cfajohnson.com Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: How cd to a directory with special characters like environment\\-?

2010-04-09 Thread Chris F.A. Johnson
or directory In such situations I find completion (TAB) really great since it does the hard quoting work for you (and does no typo). That, or up-arrow (or Ctrl-P) to recall previous command. -- Chris F.A. Johnson, http://cfajohnson.com Author: Pro Bash Programming: Scripting

Re: declare -A a=b crashes bash

2010-04-09 Thread Chris F.A. Johnson
Version: 4.0 Patch Level: 33 Release Status: release Description: Typing 'declare -A a=b' crashes bash with a segmentation fault. Repeat-By: Type 'declare -A a=b'. I can confirm that in 4.0, but it works in 4.1 Time to upgrade? -- Chris F.A. Johnson, http

Re: How cd to a directory with special characters like environment\\-?

2010-04-09 Thread Chris F.A. Johnson
On Fri, 9 Apr 2010, Greg Wooledge wrote: On Fri, Apr 09, 2010 at 11:59:20AM -0400, Chris F.A. Johnson wrote: On Fri, 9 Apr 2010, Marc Herbert wrote: Le 08/04/2010 22:58, Peng Yu a ?crit : $ mkdir environment\\- $ cd environmen\\- -bash: cd: environmen-: No such file

Re: Return status of command substitution with $(...) gets lost

2010-03-04 Thread Chris F.A. Johnson
: The $? variable is always 0 after that statement. The return status is that of the command, local. -- Chris F.A. Johnson http://cfajohnson.com === Author: Shell Scripting Recipes: A Problem-Solution Approach

Re: Namespace problem with pipe into a braced group

2010-02-23 Thread Chris F.A. Johnson
in a subshell. -- Chris F.A. Johnson http://cfajohnson.com === Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) Pro Bash Programming: Scripting the GNU/Linux Shell (2009

Re: Confused about how bash breaks input into words

2010-02-23 Thread Chris F.A. Johnson
substitution, $(date +'%Y-%m-%d'), should be treated as a single word. Yes, it is a single word. But it is subject to wordsplitting: $ print %s\n $(date +'%Y %m %d') 2010 02 23 -- Chris F.A. Johnson http://cfajohnson.com

Re: Is there a special variable for the directory where the script is in?

2010-02-11 Thread Chris F.A. Johnson
path to the file, so: ${0%/*} -- Chris F.A. Johnson http://cfajohnson.com === Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) Pro Bash Programming: Scripting the GNU

Re: Is there a special variable for the directory where the script is in?

2010-02-11 Thread Chris F.A. Johnson
On Thu, 11 Feb 2010, Eric Blake wrote: According to Chris F.A. Johnson on 2/11/2010 4:23 PM: On Fri, 12 Feb 2010, Peng Yu wrote: $0 gives the file name of the script. I could use several shell command to get the directory where the script is in. But I'm wondering if there is an easy

Re: Passing variables to and from custom programs

2010-02-07 Thread Chris F.A. Johnson
. It is used like this- myIpExec {IPaddr1} ${IPaddr2} ${IPaddr3} ${IPaddr4} Result=$? The portable equivalent is: myIpExec EOF {IPaddr1} ${IPaddr2} ${IPaddr3} ${IPaddr4} EOF -- Chris F.A. Johnson http://cfajohnson.com

  1   2   >