Re: Double-quoting of commandline args (problem if $1 as a string of more than 1 char)

2005-04-02 Thread Chris F.A. Johnson
string of more than one character. From the man page: Positional Parameters When a positional parameter consisting of more than a single digit is expanded, it must be enclosed in braces (see EXPANSION below). -- Chris F.A. Johnson http

Re: Bug (Metacharacters)...

2005-04-12 Thread Chris F.A. Johnson
. $ uname -a Linux sergio 2.6.8-2-686 #1 Mon Jan 24 03:58:38 EST 2005 i686 GNU/Linux What is your locale? It probably collates in the order 'aAbBcCdD...zZ'. -- Chris F.A. Johnson http://cfaj.freeshell.org

Re: bash script problems

2005-05-11 Thread Chris F.A. Johnson
On Thu, 12 May 2005, Tony Jo wrote: Chris F.A. Johnson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] When quoting parts of a script or error messages, please be accurate (cut and paste rather than retyping). You used: temp=`expr $val1 + $val2` or you wouldn't have received

Re: unable to redirect readonly variable error

2005-07-07 Thread Chris F.A. Johnson
is naturally going to fail). -- Chris F.A. Johnson http://cfaj.freeshell.org == Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress http://www.torfree.net/~chris/books/cfaj/ssr.html

Re: unable to redirect readonly variable error

2005-07-07 Thread Chris F.A. Johnson
$ -- Chris F.A. Johnson http://cfaj.freeshell.org == Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress http://www.torfree.net/~chris/books/cfaj/ssr.html

Re: IFS=$'\xb2'

2005-08-06 Thread Chris F.A. Johnson
. -- Chris F.A. Johnson http://cfaj.freeshell.org == Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress http://www.torfree.net/~chris/books/cfaj/ssr.html

Re: failure in pipeline not reflected in $?

2005-08-25 Thread Chris F.A. Johnson
%s\n [EMAIL PROTECTED] 1 0 1 0 -- Chris F.A. Johnson http://cfaj.freeshell.org == Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress http://www.torfree.net/~chris/books/cfaj/ssr.html

Re: mod arithmetic result 0 gives error exit status

2005-10-10 Thread Chris F.A. Johnson
otherwise. Thanks. Duane Ellis ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash -- Chris F.A. Johnson http://cfaj.freeshell.org

Re: read built-in will not read inside while loop

2005-10-10 Thread Chris F.A. Johnson
. To see what this command has read: echo REPLY=$REPLY echo $b echo $c done (ls -al ~/) exit 0 -- Chris F.A. Johnson http://cfaj.freeshell.org == Shell Scripting Recipes: A Problem-Solution Approach

Re: Alias and if

2005-12-04 Thread Chris F.A. Johnson
. #! /bin/bash Add: shopt -s expand_aliases if true; then alias myls=ls alias -p myls fi myls -- Chris F.A. Johnson http://cfaj.freeshell.org

Re: Can create BASH functions that can't be deleted

2006-01-15 Thread Chris F.A. Johnson
is $FUNCNAME; } a.b My name is a.b unset a.b -bash: unset: `a.b': not a valid identifier unset -f a.b -- Chris F.A. Johnson http://cfaj.freeshell.org === Author: Shell

Re: [bash 3.1.5] sh -c echo -n ok broken

2006-01-18 Thread Chris F.A. Johnson
ok\c to work. The older bash-3.00.15(3) works with --enable-xpg-echo-default. So, it is possible to have both the following working in sh and bash echo -n ok echo ok\c printf %s ok -- Chris F.A. Johnson http://cfaj.freeshell.org

Re: Fwd: read -n is confused by \

2006-01-27 Thread Chris F.A. Johnson
, the backslash is not considered a character, it is an escape mechanism. -- Chris F.A. Johnson http://cfaj.freeshell.org === Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress

Re: incorrect brace expansion

2006-01-29 Thread Chris F.A. Johnson
only happen when commas or sequence expressions are used, and while the inner braces used commads, the outer braces did not -mike Let's see... a-{b{d,e}}-c a-{bd,be}-c a-bd-c a-be-c It looks okey, I think. Except that b{d,e} expands to 'bd be', not 'bd,be'. -- Chris F.A

Re: make 'tr' (or something like it) a bash builtin ?

2006-02-02 Thread Chris F.A. Johnson
://cfaj.freeshell.org/shell/bash/loadables/. Second, is William Park's bash extension at: http://home.eol.ca/~parkw/index.html#bash. -- Chris F.A. Johnson http://cfaj.freeshell.org === Author: Shell

Re: make 'tr' (or something like it) a bash builtin ?

2006-02-05 Thread Chris F.A. Johnson
$ echo ${foo^^} ## Convert all characters BAR $ echo ${foo^[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://cfaj.freeshell.org

Re: command history

2006-02-24 Thread Chris F.A. Johnson
## shift+down-arrow You may need to adjust the bindings for your terminal. -- Chris F.A. Johnson http://cfaj.freeshell.org === Author: Shell Scripting Recipes: A Problem-Solution

Re: (no subject)

2006-08-02 Thread Chris F.A. Johnson
+X ] || echo hello -- Chris F.A. Johnson http://cfaj.freeshell.org === Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) ___ Bug

Re: incorrect brace expansion when using default values

2006-09-06 Thread Chris F.A. Johnson
? -- Chris F.A. Johnson http://cfaj.freeshell.org === Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) ___ Bug-bash mailing list Bug-bash

Re: read 1 var in when executing command

2007-05-13 Thread Chris F.A. Johnson
Not sure how to do it. I have been looking around and saw things like getopts, but I am only passing in one variable and thought it should be fairly simple whois $1 | grep ... -- Chris F.A. Johnson http://cfaj.freeshell.org

Re: Generating unique file names

2007-05-13 Thread Chris F.A. Johnson
-- Chris F.A. Johnson http://cfaj.freeshell.org === Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) ___ Bug-bash mailing list Bug-bash

Re: prefilling keyboard buffer

2007-06-16 Thread Chris F.A. Johnson
Press up arrow to edit \$default\: XX -- Chris F.A. Johnson http://cfaj.freeshell.org === Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress

Re: automate input

2007-08-09 Thread Chris F.A. Johnson
' $svnRoot/$projectName $'\r' CONFIRM ... yes | trac-admin $tracRoot/$projectName initenv -- Chris F.A. Johnson http://cfaj.freeshell.org === Author: Shell Scripting Recipes: A Problem-Solution

Re: bash root ~/.bash_profile quirk

2007-09-06 Thread Chris F.A. Johnson
... should I use su - ? If you use su -, it does the equivalent of logging in, and thus reads .bash_profile; su by itself doesn't. -- Chris F.A. Johnson http://cfaj.freeshell.org === Author: Shell

Re: Wrong input confuses bash's arithmetic unit permanently

2007-09-12 Thread Chris F.A. Johnson
? -- Chris F.A. Johnson http://cfaj.freeshell.org === Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) .

Re: reading whitespaces and beginning and end of line

2007-12-07 Thread Chris F.A. Johnson
this whitespace get automatically truncated from $line, and i dont want that..i want the whole line to go into outfile, no matter if the last characters are whitespace! while IFS= read -r line do printf %s\n $line done infile -- Chris F.A. Johnson, webmaster http://Woodbine

Re: `read' builtin does not take last record without trailing delimiter

2008-02-26 Thread Chris F.A. Johnson
people think of this? I wouldn't use that method to populate an array. echo 0 1 2^3 4 5^6 7 8 | { read line IFS=^ array=( $line ) printf %s\n [EMAIL PROTECTED] } -- Chris F.A. Johnson, webmaster http://Woodbine-Gerrard.com

Re: Possible eval builtin speedup?

2008-03-05 Thread Chris F.A. Johnson
about it? Would it be a difficult task? It is more likely to be the command substitution that is slow. -- Chris F.A. Johnson, webmaster http://Woodbine-Gerrard.com === Author: Shell Scripting Recipes

Re: shorthand attempt at 'basename file .ext'

2008-03-27 Thread Chris F.A. Johnson
command at: http://cfaj.freeshell.org/shell/scripts/basename-sh. -- Chris F.A. Johnson, webmaster http://Woodbine-Gerrard.com === Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) .

Re: shorthand attempt at 'basename file .ext'

2008-03-29 Thread Chris F.A. Johnson
On 2008-03-28, Eric Blake wrote: Chris F.A. Johnson cfajohnson at gmail.com writes: You can find a shell function to replace the external basename command at: http://cfaj.freeshell.org/shell/scripts/basename-sh. Except that your example is not POSIX-compliant. POSIX requires

Re: read -d on a terminal

2008-06-20 Thread Chris F.A. Johnson
. -- Chris F.A. Johnson, webmaster http://Woodbine-Gerrard.com === Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) .

Re: some variable level issues

2008-06-30 Thread Chris F.A. Johnson
, it appears to be very slow compared to $(file). Any thoughts? var=$( cat file; echo . ) var=${var%.} -- Chris F.A. Johnson, webmaster http://Woodbine-Gerrard.com === Author: Shell Scripting Recipes: A Problem-Solution

Re: Bash/readline enhancement: wish to pre-set initial value of input text

2008-07-09 Thread Chris F.A. Johnson
On 2008-07-08, Richard Neill wrote: Dear All, When using read, it would be really neat to be able to pre-fill the form with a default (or previous) value. For example, a script which wants you to enter your name, and thinks that my name is Richard, but that I might want to correct it.

Re: inconsistent treatment of backslash-bang

2008-07-16 Thread Chris F.A. Johnson
) seems to fix the problem: Unfortunately, this violates Posix and traditional sh behavior. If you want fully sh-compatible behavior, you have to turn off history expansion (set +o history). I find it adequate to set histchars to an empty string. -- Chris F.A. Johnson, webmaster

Re: bash: request for a way to return variables to the parent of a subshell

2008-07-22 Thread Chris F.A. Johnson
} -- Chris F.A. Johnson, webmaster http://Woodbine-Gerrard.com === Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: function name bug ?

2008-07-30 Thread Chris F.A. Johnson
F.A. Johnson, webmaster http://Woodbine-Gerrard.com === Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: how do I write a shell script to batch rename files in a directory?

2008-08-29 Thread Chris F.A. Johnson
%\?} done -- Chris F.A. Johnson, webmaster http://Woodbine-Gerrard.com === Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: File renaming using SED in BASH

2008-09-21 Thread Chris F.A. Johnson
in * do chg=$( echo $f | sed 's:(www.somewhere.net)::' ) mv $f $chg done -- Chris F.A. Johnson, webmaster http://Woodbine-Gerrard.com === Author: Shell Scripting Recipes: A Problem-Solution Approach (2005

Re: nullglob breaks unset of arrays

2008-09-25 Thread Chris F.A. Johnson
unset my_array[0] echo Array [EMAIL PROTECTED] shopt -s nullglob # remove first entry unset my_array[0] There is no longer any my_array[0] to unset. Try: unset my_array[1] echo Array [EMAIL PROTECTED] -- Chris F.A. Johnson, webmaster http

Re: [bash 3.2.39] File descriptor 10 is always duplicated from 0 and cannot be closed

2008-10-31 Thread Chris F.A. Johnson
- ) -- Chris F.A. Johnson, webmaster http://Woodbine-Gerrard.com === Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: Is this a bash wildcard bug?

2008-11-20 Thread Chris F.A. Johnson
-- 1 root root 0 Nov 20 12:22 xA # ls -l x[A-Z] -rw-r--r-- 1 root root 0 Nov 20 12:22 xA Any ideas? You are using a locale that conflates upper- and lowercase as aAbBcC...yYzZ. Try it with: export LC_ALL=C -- Chris F.A. Johnson, webmaster http://Woodbine-Gerrard.com

Re: [bash-testers] Re: case modification operators misbehaviour?

2009-01-14 Thread Chris F.A. Johnson
(for Tesst then), but for all s, of course. man bash4: ... the ^ and , expansions match and convert only the first character. -- Chris F.A. Johnson, webmaster http://Woodbine-Gerrard.com === Author

Terminal state with read -st1

2009-02-27 Thread Chris F.A. Johnson
In bash4.0, the terminal is not reset if this is times out: read -st1 -- Chris F.A. Johnson, webmaster http://Woodbine-Gerrard.com === Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Completion crashes the shell

2009-03-02 Thread Chris F.A. Johnson
...Aborted -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com === Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: Completion crashes the shell

2009-03-02 Thread Chris F.A. Johnson
it. -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com = Do not reply to the From: address; use Reply-To: Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Feature request

2009-03-10 Thread Chris F.A. Johnson
I would like to see read's -d option expanded to accept a string of characters, any one of which would terminate input. The character which terminates input should be stored in a variable, e.g., $REPLY_END. -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com

Re: delete elements from an array...

2009-03-11 Thread Chris F.A. Johnson
=$(( $n + 1 )) done printf %s\n ${arra...@]} echo printf %s\n ${arra...@]} -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com = Do not reply to the From: address; use Reply-To: Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: loop through records

2009-03-11 Thread Chris F.A. Johnson
\n $1 $2 done -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com = Do not reply to the From: address; use Reply-To: Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: using mapfile is extreamly slow compared to oldfashinod ways to read files

2009-03-26 Thread Chris F.A. Johnson
(sed -e 's/^ *//' -e 's/ *$//' file) Chet, how about an option to mapfile that strips leading and/or trailing spaces? Another useful option would be to remove newlines. -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com = Do not reply to the From: address

Re: using mapfile is extreamly slow compared to oldfashinod ways to read files

2009-03-27 Thread Chris F.A. Johnson
by mapfile? Time the mapfile command and the loop separately: time mapfile file time for i in ${mapfi...@]} -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com === Author: Shell Scripting Recipes

Re: feature-request: brief syntax for $(type -p somecommand)

2009-04-02 Thread Chris F.A. Johnson
to be annoying. Use a function, e.g.: p() { pp=$( type -p $@ ) } -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com = Do not reply to the From: address; use Reply-To: Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: feature-request: brief syntax for $(type -p somecommand)

2009-04-02 Thread Chris F.A. Johnson
On Thu, 2 Apr 2009, Mike Coleman wrote: On Thu, Apr 2, 2009 at 11:33 AM, Chris F.A. Johnson c...@freeshell.org wrote: On Thu, 2 Apr 2009, Mike Coleman wrote: [Oops--I sent that incomplete.] It would be nice if there was some really brief syntax for $(type -p somecommand) I find myself

Re: Brace expansion

2009-04-04 Thread Chris F.A. Johnson
numbers. 08 and 08 ar enot valid octal numbers. for i in 0{1..9} 10; do printf %02d\n $[i#0};done Or: printf %02d\n {1..10} Or, in bash4.0: printf %s\n {01..10} -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com = Do not reply to the From: address

Re: how to pass arguments with space inside?

2009-04-09 Thread Chris F.A. Johnson
archive at Nabble.com. -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com = Do not reply to the From: address; use Reply-To: Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: how to pass arguments with space inside?

2009-04-11 Thread Chris F.A. Johnson
fail! http://mywiki.wooledge.org/BashFAQ/005 How can I use array variables? -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com = Do not reply to the From: address; use Reply-To: Author: Shell Scripting Recipes: A Problem-Solution Approach (2005

Re: passing arrays as parameters to functions

2009-04-18 Thread Chris F.A. Johnson
parameters are my two integer arguments, but I'd like them to be optional. The size of the array is not fixed. func() { local f_array eval f_array=( \\${...@]}\ ) printf %s\n ${f_arr...@]} } a=( qw er ty ui op ) func a -- Chris F.A. Johnson, webmaster http://woodbine

extglob

2009-05-15 Thread Chris F.A. Johnson
Am I missing something, or are these extended globbing patterns equivalent to a plain asterisk? ?(pattern-list) Matches zero or one occurrence of the given patterns *(pattern-list) Matches zero or more occurrences of the given patterns -- Chris F.A. Johnson, webmaster http

Re: extglob

2009-05-16 Thread Chris F.A. Johnson
On Sat, 16 May 2009, Pierre Gaston wrote: On Sat, May 16, 2009 at 2:44 AM, Chris F.A. Johnson c...@freeshell.org wrote: Am I missing something, or are these extended globbing patterns equivalent to a plain asterisk? ?(pattern-list) Matches zero or one occurrence of the given

read -e bug

2009-05-27 Thread Chris F.A. Johnson
This is nothing new; it happens in all versions of bash: printf Enter something: read -e whatever Press a key, then cursor left (or ^A); the cursor moves to the beginning of the line, over E instead of over the character just entered. -- Chris F.A. Johnson, webmaster http

Re: read -e bug

2009-05-28 Thread Chris F.A. Johnson
. This isn't a bug; that's where readline thinks the cursor is. Why would it think that? It's wrong. If you want to use a prompt, use `read -p'. I like to write portable scripts; read -p is not portable. -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com

Help help missing m option in synopsis

2009-05-29 Thread Chris F.A. Johnson
time consumed by pipeline's execution. times - Display process times. read - Read a line from the standard input and split it into fields. readarray - Read lines from a file into an array variable. readonly - Mark shell variables as unchangeable. -- Chris F.A. Johnson, webmaster http

Re: $\n doesn't get expanded between double-quotes

2009-07-03 Thread Chris F.A. Johnson
X=a$'\n'b cwill do it, but that is really really ugly. X=$'a\nb c' -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com === Author: Shell Scripting Recipes: A Problem-Solution Approach (2005

Re: $\n doesn't get expanded between double-quotes

2009-07-03 Thread Chris F.A. Johnson
-quotes, may I request this as a functionality change? -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com === Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

mapfile callback

2009-07-17 Thread Chris F.A. Johnson
mapfile callback code is executed in a subshell. Would it be possible to make it execute in the current shell? With mapfile -c1, this would make it possible to work on a file without an explicit loop, making it much faster. -- Chris F.A. Johnson http

Re: mapfile callback

2009-07-19 Thread Chris F.A. Johnson
On Sun, 19 Jul 2009, Chet Ramey wrote: Chris F.A. Johnson wrote: mapfile callback code is executed in a subshell. It's not. It's executed in the same context as an `eval' or a trap command. So it is. Great! I wonder what I was doing wrong before. -- Chris F.A. Johnson

Re: mapfile callback

2009-07-20 Thread Chris F.A. Johnson
On Mon, 20 Jul 2009, Pierre Gaston wrote: On Mon, Jul 20, 2009 at 5:46 AM, Chris F.A. Johnson c...@freeshell.orgwrote: On Sun, 19 Jul 2009, Chet Ramey wrote: Chris F.A. Johnson wrote: mapfile callback code is executed in a subshell. It's not. It's executed in the same context

Re: read -t 0 not supported? (poll)

2009-07-22 Thread Chris F.A. Johnson
On Wed, 22 Jul 2009, Marc Herbert wrote: It seems polling using read -t 0 is not supported. It is supported in bash 4.0. -- Chris F.A. Johnson http://cfaj.freeshell.org === Author: Shell

Re: Errors when patching bash4.0

2009-07-22 Thread Chris F.A. Johnson
file. What am I doing wrong? Thanks, -Alex -- Chris F.A. Johnson http://cfaj.freeshell.org === Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: Bash script file naming problem?

2009-07-25 Thread Chris F.A. Johnson
or aliases. The command to use is 'type'. With the -a option, it will tell you all of the possible commands that use the name. If you have a command, a function and an alias with the same name, it will list all three. -- Chris F.A. Johnson, webmaster http://woodbine

Ordering in associative array expansion

2009-07-28 Thread Chris F.A. Johnson
What is the algorithm for order of expansion of associative arrays? Single-letter subscripts are expanded alphabetically, but longer subscripts are not. -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com

Re: parse error running builtins from array

2009-07-29 Thread Chris F.A. Johnson
, and playing around with them has not helped. Does anyone have a way out of this? Take a look at the arguments you are actually using: printf %s\n ${cc[1]} Use eval: for e in 0 1 2 do eval ${cc[$e]} done -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com

Re: parse error running builtins from array

2009-07-29 Thread Chris F.A. Johnson
On Wed, 29 Jul 2009, mk27 wrote: Take a look at the arguments you are actually using: [root~] printf %s ${cc[1]} bash-ctimels-l Again, I can't see the missing Try using the code I posted: printf %s\n ${cc[1]} -- Chris F.A. Johnson, webmaster http://woodbine

read -t0 doesn't pick up waiting characters

2009-08-08 Thread Chris F.A. Johnson
, they are empty. They do pick up the characters if I change delay to .0001. -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com === Author: Shell Scripting Recipes: A Problem-Solution Approach

Re: unset associative array may cause segfault

2009-08-25 Thread Chris F.A. Johnson
a patch for it? It's not fixed with the patches posted so far. -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com === Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: doing simple math in bash :: prb with leading zero

2009-09-01 Thread Chris F.A. Johnson
are you getting the value 'lastmo' from? If from 'something like date +%m', maybe you could strip off the leading zero? I.e.: lastmo=$(echo $lastmo|sed -r 's/0+([0-9])/\1/') Surely you mean: lastmo=${lastmo#0} -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com

Re: doing simple math in bash :: prb with leading zero

2009-09-01 Thread Chris F.A. Johnson
On Tue, 1 Sep 2009, ken wrote: Doing very simple math in bash fails if a number begins with a zero (0). Numbers beginning with 0 are base 8 (octal). 08 and 09 are not valid octal numbers. -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com

Re: Strange compgen behaviour

2009-09-24 Thread Chris F.A. Johnson
the argument to -W on $IFS _and_ whitespace. Or am I missing something? -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com === Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: Bug in array populating does not respect quotes

2009-09-24 Thread Chris F.A. Johnson
in a variable does not handle quotes. Repeat-By: ~$ declare -a samplearray ~$ samplearray=( x y 'z k') ~$ echo ${samplearray[2]} z k ~$ samplestring=x y 'z k' ~$ samplearray=( $samplestring ) eval samplearray=( $samplestring ) ~$ echo ${samplearray[2]} 'z -- Chris F.A. Johnson

Re: Real easy questions. Please answer

2009-09-25 Thread Chris F.A. Johnson
but that just seems stupid That's a perfectly good way of doing it, but you will want to turn off filename expansion if there's a chance that the value may contain wildcards: set -f Counter $IDs set +f -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com

Re: ignoring comments in a 'cat' call

2009-10-07 Thread Chris F.A. Johnson
' ' -f1 programs) -y -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com === Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Re: Cannot form valid test expressions that involve brackets as string comparison targets

2009-10-07 Thread Chris F.A. Johnson
:1} = ( ]#-a ${basePic:4:1} = ) ] then echo Got brackets fi if [ ${basePic:0:1} = '\(' ] #-a ${basePic:4:1} = '\)' ] then echo Got brackets fi -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com

Re: [OT] Re: how to start in overwrite-mode

2009-10-28 Thread Chris F.A. Johnson
no functions at all. Had. Only before 1984. Since then it has had functions. The first shell I used, the Bourne shell on ATT SVR3.2, had functions. -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com

Re: OT: Getting MySQL fields with embedded spaces into array

2009-10-29 Thread Chris F.A. Johnson
: printf -v IFS \n -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com === Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) Pro Bash Programming: Scripting the GNU/Linux Shell

Re: value too great for base (error token is 0008)

2009-11-04 Thread Chris F.A. Johnson
POSIX and without a loop by using an intermediate variable: foo=00081 bar=${foo%%[!0]*} foo=${foo#$bar}} Or even without an intermediate variable: foo=${foo#${foo%%[!0]*}} (Though I prefer the variable for legibility.) -- Chris F.A. Johnson, webmaster http://woodbine

Re: Error handling question

2009-11-09 Thread Chris F.A. Johnson
an error I just append || true to the corresponding command. -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com === Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) Pro Bash

Re: IFS handling and read

2009-11-30 Thread Chris F.A. Johnson
-0 All of a sudden, x is not set (or set to the wrong value). So it should be the *first* command, not the last, that is executed in the calling shell. -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com

Re: IFS handling and read

2009-11-30 Thread Chris F.A. Johnson
. 1:2 . This works with the output of commands, too: IFS=- read year month day . $(date +%Y-%m-%d) . -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com === Author: Shell Scripting Recipes: A Problem

Re: IFS handling and read

2009-11-30 Thread Chris F.A. Johnson
On Mon, 30 Nov 2009, Lhunath (Maarten B.) wrote: On 30 Nov 2009, at 15:56, Chris F.A. Johnson wrote: On Mon, 30 Nov 2009, Greg Wooledge wrote: On Mon, Nov 30, 2009 at 11:46:03AM +0100, Lhunath (Maarten B.) wrote: Don't use pipelines to send streams to read. Use file redirection

Re: best way to test for empty dir?

2009-12-11 Thread Chris F.A. Johnson
On Fri, 11 Dec 2009, Sven Mascheck wrote: ... comp.unix.shell might match well here and could be entertaining - IMHO worth to migrate; objections? This has been discussed more than once in c.u.s; check the archives. -- Chris F.A. Johnson, webmaster http://woodbine

Re: best way to test for empty dir?

2009-12-11 Thread Chris F.A. Johnson
On Fri, 11 Dec 2009, Antonio Macchi wrote: is_file() { [ -f $1 ] return return 1 } is_file /path/to/dir/* || echo empty you don't need to check more than the first element You may need to; it depends on the statement of the problem. -- Chris F.A. Johnson

Re: add a way to declare global variables

2009-12-12 Thread Chris F.A. Johnson
of the variable. Of the three, local is the only command I use. It says exactly what it does. -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com === Author: Shell Scripting Recipes: A Problem-Solution

Re: BASH Command substitution

2009-12-17 Thread Chris F.A. Johnson
suitable location. -- Chris F.A. Johnson, webmaster http://woodbine-gerrard.com === Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) Pro Bash Programming: Scripting the GNU/Linux Shell

Re: bash killed by filecompletion feature if filename(s) contain '*' character

2010-01-30 Thread Chris F.A. Johnson
] No problem here in 3.2, 4.0 or 4.1 -- Chris F.A. Johnson http://cfajohnson.com === Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) Pro Bash Programming: Scripting the GNU

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

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: 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: 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: 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

  1   2   >