Re: |& in bash?

2013-01-22 Thread Steven W. Orr
On 1/21/2013 1:20 PM, John Caruso wrote: In article , Dan Douglas wrote: It isn't very common to dump multiple streams into one pipe. echo "n't very" >/dev/null 2>&1 I suggest avoiding |&. Personally I wouldn't use it in scripts, since I try to stick as close to plain vanilla Bourne shell

Re: xargs combined with awk

2012-12-20 Thread Steven W. Orr
On 12/20/2012 10:43 AM, giuseppe.amatu...@gmail.com wrote: Hi, have this a for loop which is sending the "dir" variable one for each processor. for dir in UA_tile_tif_pop_txt UA_buf10_tile_tif_pop_txt UA_buf20_tile_tif_pop_txt UA_buf30_tile_tif_pop_txt UA_buf40_tile_tif_pop_txt UA_buf50_tile_

Re: Question about the return value of 'local'

2012-12-14 Thread Steven W. Orr
On 12/14/2012 12:07 PM, Bill Gradwohl wrote: I'm not trying to start a war, but ... Has anyone entertained the idea of getting rid of the man pages and the info system? Those are relics of the tty era. We have graphical interfaces today with capabilities that could enhance providing and then fin

Re: devel branch build failure

2012-12-12 Thread Steven W. Orr
On 12/12/2012 9:40 AM, Chet Ramey wrote: On 12/12/12 8:56 AM, Raphaƫl Droz wrote: Hi, using the devel/ branch, linking fails with: bashline.o: In function `attempt_shell_completion': bashline.c:1406: undefined reference to `parser_in_command_position' collect2: ld returned 1 exit status I se

Re: Why can't I say "&>&3"? Bug or feature?

2012-12-06 Thread Steven W. Orr
On 12/6/2012 12:06 PM, DJ Mills wrote: On Thu, Dec 6, 2012 at 6:11 AM, Dan Douglas wrote: I don't like &> to begin with. It makes the already cryptic redirection syntax that beginners struggle to understand even more confusing by adding a pointless shortcut with a non-obvious meaning instead o

Re: Any chance of multi-dimensional arrays?

2012-11-25 Thread Steven W. Orr
On 11/25/12 14:54, quoth Bob Proulx: Rene Herman wrote: All I want additionally is multi-dimensional arrays... There are various naming conventions and schemes to simulate multi-dimensional arrays using single dimension arrays. Since you want to continue with the shell and the shell has not (

bug-bash@gnu.org

2012-10-12 Thread Steven W. Orr
On 10/12/12 06:55, quoth Sergey Fadeev: Why doesn't it exit the shell? $ set -e $ echo $(false) Shouldn't the error code of $(false) command substitution be checked by set -e before passing stdout to the echo builtin? Isn't it the most logical behavior that most people would expect of se

Re: a recursion bug

2012-10-02 Thread Steven W. Orr
On 10/02/12 14:03, quoth Linda Walsh: Greg Wooledge wrote: I see a system message from the original posters program: Segmentation fault (core dumped) Finding it is left as an exercise to the reader. It is noted that many programs catch fatal signals in order to not leave evidence of their

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

2012-09-11 Thread Steven W. Orr
On 09/11/12 17:20, quoth Chris F.A. Johnson: On Tue, 11 Sep 2012, Benoit Vaugon wrote: ... Description: Cannot use "case" construction in a "for" loop in a $() sub shell. Should work but produces parsing error. Repeat-By: echo $(for x in whatever; do case y in *) echo 42;; esac; done)

Re: AIX and Interix also do early PID recycling.

2012-07-25 Thread Steven W. Orr
On 7/25/2012 9:20 AM, Michael Haubenwallner wrote: On 07/25/2012 09:59 AM, Michael Haubenwallner wrote: On 07/25/2012 03:05 AM, Chet Ramey wrote: Bash holds on to the status of all terminated processes, not just background ones, and only checks for the presence of a newly-forked PID in that li

Re: AIX and Interix also do early PID recycling.

2012-07-25 Thread Steven W. Orr
On 7/25/2012 8:14 AM, Greg Wooledge wrote: On Wed, Jul 25, 2012 at 09:59:28AM +0200, Michael Haubenwallner wrote: OTOH, AFAICT, as long as a PID isn't waitpid()ed for, it isn't reused by fork(). However, I'm unable to find that in the POSIX spec. A process that hasn't been waited for should be

Re: .bashrc is sourced even for non-interactive shells (when run from sshd)

2012-06-04 Thread Steven W. Orr
On 6/4/2012 9:55 AM, Chet Ramey wrote: That's not exactly it, but the idea is right. isnetconn() (previously issock()) has been around since bash-1.13. If I had to guess, I'd say late August 1992 or 1993. It wasn't inherited from csh. The original requests were along the lines of having som

I have a bash style question. Feedback request.

2012-04-20 Thread Steven W. Orr
I manage a hefty collection of bash scripts. Sometimes, I make heavy use of pushd and popd. When problems come up, the directory stack can make debugging more complicated than I'd like. One thing I did to get better control over things was to write a dstack module that provides pushd and popd fu

Re: inconsistency with "readonly" and scope

2012-04-12 Thread Steven W. Orr
On 4/12/2012 4:21 PM, dethrophes wrote: Am 12.04.2012 22:11, schrieb Steven W. Orr: On 4/12/2012 2:16 PM, dethrophes wrote: Am 12.04.2012 14:27, schrieb Chet Ramey: On 4/11/12 4:12 PM, dethrophes wrote: I've also noticed weird behavior with "declare -gr" the r sometimes se

Re: inconsistency with "readonly" and scope

2012-04-12 Thread Steven W. Orr
On 4/12/2012 2:16 PM, dethrophes wrote: Am 12.04.2012 14:27, schrieb Chet Ramey: On 4/11/12 4:12 PM, dethrophes wrote: I've also noticed weird behavior with "declare -gr" the r sometimes seems to override the g, but not specific to functions It seems to be specific either to the source file or

Re: semicolon at beginning of line

2012-04-08 Thread Steven W. Orr
On 4/7/2012 4:00 PM, Elliott Forney wrote: I wish bash would happily execute lines that begin with a semicolon, i.e., treat it as a no-op followed by a command. The following examples come to mind: $ infloop& echo hello [2] 11361 hello $ infloop&; echo hello bash: syntax error near unexpected

Re: Expanding aliases to full command before execution

2012-04-03 Thread Steven W. Orr
On 4/3/2012 5:22 PM, jrrand...@gmail.com wrote: Hi everyone, In bash, is it possible to expand my aliases either before they are executed or when they are stored in the history file? For example, if I have: alias ll='ls -l' defined in my .bashrc, when I execute "ll" from the command line, I'd

Re: RFE: history without line numbers

2012-03-13 Thread Steven W. Orr
On 3/13/2012 5:27 AM, Biltong wrote: To make copy-pasting between different terminals work better, would it be possible for the history built-in to support an option to suppress line numbers? Why would you want that? 507 spam xxx.eml 508 cd .jpilot 509 grep -i poisson AddressDB.pdb

Re: bash 4.2 breaks source finding libs in lib/filename...

2012-03-03 Thread Steven W. Orr
It could be even furthermore separated from the traditional "source" and a new keyword introduced like "require" a la lisp which would be able to do things like: 1) load the file, searching in the BASH_LIB_PATH (or other variables) for a file with optionally the extension .sh or .bash 2) only lo

Re: Inconsistent quote and escape handling in substitution part of parameter expansions.

2012-02-28 Thread Steven W. Orr
On 2/28/2012 11:54 AM, John Kearney wrote: On 02/28/2012 05:22 PM, Roman Rakus wrote: On 02/28/2012 05:10 PM, John Kearney wrote: wrap it with single quotes and globally replace all single quotes in the string with '\'' single quote and slash have special meaning so they have to be escaped, th

Re: Pathname expansion not performed in Here Documents

2012-02-27 Thread Steven W. Orr
On 2/27/2012 1:26 AM, Pierre Gaston wrote: On Mon, Feb 27, 2012 at 6:44 AM, Davide Baldini wrote: On 02/27/12 05:04, DJ Mills wrote: Think of regular here-doc (with an unquoted word) as being treated the same way as a double-quoted string Thank you Mills, of course I can understand it _now_

Re: exit status issue

2011-11-22 Thread Steven W. Orr
On 11/22/2011 6:49 PM, Bob Proulx wrote: Dallas Clement wrote: This doesn't (yet) look like a problem with bash. Admittedly bash seems to do the right thing if you go by the set -x execution trace. If you go by that, it would indeed seem that the call to touch is failing. I have a higher le

Re: How to match regex in bash? (any character)

2011-09-26 Thread Steven W. Orr
On 9/26/2011 9:19 PM, Peng Yu wrote: Hi, I know that I should use =~ to match regex (bash version 4). However, the man page is not very clear. I don't find how to match (matching any single character). For example, the following regex doesn't match txt. Does anybody know how to match any ch

Re: YAQAGV (Yet Another Question About Global Variables)

2011-08-23 Thread Steven W. Orr
On 8/23/2011 9:52 AM, Greg Wooledge wrote: On Tue, Aug 23, 2011 at 09:42:21AM -0400, Steven W. Orr wrote: Since require is a function, any variables that are declared in a required module which declare global variables using typeset then become local variables to the require function. Then

YAQAGV (Yet Another Question About Global Variables)

2011-08-23 Thread Steven W. Orr
I made a decision to implement the require module written by Noah Friedman that comes in the examples part of the bash distro. This is the trick for implementing the provide / require functionality of features. I love it. It works great. I just ran into one little snag. Not a show stopper, but

Is this a bug in [[ -f ]]?

2011-08-18 Thread Steven W. Orr
I have a symlink file and if if I test it I get success status with -f. 831 > ls -l errio err lrwxrwxrwx. 1 sorr fc5 Aug 18 08:48 err -> errio -rw-rw-r--. 1 sorr fc 3816 Aug 18 08:48 errio 832 > [[ -f errio ]] 833 > echo $?# Good answer 0 *834 > [[ -h errio ]] 835 > echo $?

Re: equivalent of Linux readlink -f in pure bash?

2011-08-09 Thread Steven W. Orr
On 8/9/2011 5:29 AM, Bernd Eggink wrote: On 09.08.2011 03:44, Jon Seymour wrote: Has anyone ever come across an equivalent to Linux's readlink -f that is implemented purely in bash? You can find my version here: http://sudrala.de/en_d/shell-getlink.html As it contains some corrections from G

Who's the target? Was: Inline `ifdef style` debugging

2011-08-08 Thread Steven W. Orr
On 8/8/2011 2:38 PM, Roger wrote: On Mon, Aug 08, 2011 at 01:20:25PM -0400, Steven W. Orr wrote: Two things: 1. Worrying about lost cycles every time you call _debug because it checks to see if debug is True is pretty miserly. If you *really* have to worry about that kind of economics then

Re: Inline `ifdef style` debugging

2011-08-08 Thread Steven W. Orr
On 8/8/2011 1:09 PM, Roger wrote: On Mon, Aug 08, 2011 at 08:56:36AM -0500, Dennis Williamson wrote: On Mon, Aug 8, 2011 at 3:47 AM, Roger wrote: I'm doing some research for one of my scripts and always liked the C style ifdef inline debug statements. ... Another way to write the _debug() f

Re: Another mapfile question.

2011-08-05 Thread Steven W. Orr
On 8/5/2011 9:08 AM, Maarten Billemont wrote: IFS= aa=() while read line do aa+=("$line") done< fn You should really put that IFS= on your 'read', so as not to break the default wordsplitting for the rest of your script: For purposes of giving concise examples on this email list, I wrote

Re: how to enable thread

2011-08-04 Thread Steven W. Orr
On 8/4/2011 9:51 AM, lina wrote: Actually I got a bash script which contains several process (jobs) The waiting time is so long, I mean, run one by one, I can submit one by one separately I can see the cores were used 100% one by one, but it's better use some bash script so I can easily modify

Another mapfile question.

2011-08-04 Thread Steven W. Orr
I never even noticed that mapfile exists. I read the section, I googled the galaxy to look for example usage, and I am stuck as to why this is A Good Thing. Is there an example of how to use this that uses the callback feature? And why is this preferable to using a while read loop? I'd just like

Re: feature request: option to start script not from the very beginning of file

2011-08-02 Thread Steven W. Orr
On 8/2/2011 9:05 AM, Dmitry Bolshakov wrote: hi perl has "-x" switch which makes it skip leading file contents until the #!/bin/perl line imho it would be good to have the same feature in bash Huge misteak. The shebang is processed by the exec system call. As such, it must occupy the first

Re: minor bash man page "cd -" annoyance

2011-07-27 Thread Steven W. Orr
On 7/26/2011 10:45 PM, Jason Quinn wrote: In the bash man page's section for "cd" it says An argument of - is equivalent to $OLDPWD. If a non-empty directory name from CDPATH is used, or if - is the first argument, and the directory change is successful, the absolute pathname of the new working

Re: How to do? Possible?

2011-07-25 Thread Steven W. Orr
On 7/25/2011 5:20 AM, Linda Walsh wrote: I got great help in learning about how to do the perl equiv of (var1, var2, var3)= (list) using read var1 var2 var3<<<(list). I use it often to get back lists of values from subroutine calls, but with sometimes useful, and sometimes hindering fact tha

Re: Built-in printf Sits Awkwardly with UDP.

2011-07-18 Thread Steven W. Orr
On 7/18/2011 10:14 AM, Ralph Corderoy wrote: Hi, (I'm not subscribed to the list so please keep me CC'd.) Consider printf 'foo bar\n'>/dev/udp/localhost/4242 with bash's printf built-in, it works fine. One packet is sent. However, make that two lines printf 'foo\nbar\n'>/dev/udp/l

Re: Problem with line buffered IO when no tty

2011-07-07 Thread Steven W. Orr
On 7/7/2011 9:21 AM, Eric Blake wrote: On 07/07/2011 06:55 AM, Steven W. Orr wrote: So, why is it that bash is behaving like it is always line buffered or unbuffered, even if there is no console? Because POSIX requires 'sh' to behave like it is unbuffered: http://pubs.ope

Re: Problem with line buffered IO when no tty

2011-07-07 Thread Steven W. Orr
On 7/7/2011 8:48 AM, Andreas Schwab wrote: "Steven W. Orr" writes: But, I actually do get line buffered IO. No, you don't. I get the stdout stuff as it happens, and the stderr stuff when that happens. Every process flushes its output when it exits. If you run this prog

Problem with line buffered IO when no tty

2011-07-07 Thread Steven W. Orr
I have a problem with whether things should or should not be line buffered vs. fully buffered. Here's the deal: #! /bin/bash sleep 6 cat <&2 And two more to stderr EOF exit 22 When I run this program, it does what it's supposed to do. I get two lines of output going to stdout (after 6 second

Re: Negative indexes in ${arr[@]:off:length}

2011-06-27 Thread Steven W. Orr
On 6/27/2011 10:25 AM, Chet Ramey wrote: I don't even understand what the second one is supposed to mean at all -- the :1: means to start with "b" and the -2 means to go back 2 elements...? How do you derive "a c" from any possible interpretation of this? I assume that he wants to be able to t

Question about patterns

2011-06-23 Thread Steven W. Orr
I may be wrong, but I think there's a way to do what I want without using a regex. I have a file called foo-1.2-3.tar.gz I need to set a variable equal to foo-1.2-i386-x86_64-3.tar.gz Is there a way to do this without parsing my brains out? I am facile with the variable operations like # ## %

Re: pushd, popd and dirs of different bash processes communicate by an external file

2011-06-10 Thread Steven W. Orr
On 6/9/2011 11:42 PM, Peng Yu wrote: Hi, I'm wondering if there is a way that different bash processes share the same stack. One way of doing so is to use a file to save the stack. It is not difficult to implement this function myself, but I'm just wondering if there is any simpler solution or a

Question about testing with variable operators

2011-06-10 Thread Steven W. Orr
I am using arithmetic tests where the test operator is passed in as an arg and it works just fine. foo() { (( $1 $2 $3 )) } foo 5 '>' 7 But I figured that if this works for arithmetic, it should also work with the test operator. It seems to not work: 514 > bar() > { > [[ $1 $2 ]] ba

Re: Stumped on a question of scoping and unset.

2011-05-26 Thread Steven W. Orr
On 5/26/2011 8:18 AM, Greg Wooledge wrote: On Wed, May 25, 2011 at 05:15:28PM -0400, Steven W. Orr wrote: In addition, I wrote (what I thought was pretty clever) a function called glob_array: glob_array() { [[ snip ]] while (( $# )) do arrayname=$1 pattern=&qu

Stumped on a question of scoping and unset.

2011-05-25 Thread Steven W. Orr
I picked up a cool routine called upvars from this location: http://fvue.nl/wiki/Bash:_Passing_variables_by_reference I've been using it a lot, but I just ran into a debugging nightmare that I do not understand. I'm using the upvars function described in the link above. In addition, I wrote (w

Re: Yet another quoting question

2011-05-06 Thread Steven W. Orr
On 5/6/2011 12:05 PM, Chet Ramey wrote: On 5/6/11 12:00 PM, Greg Wooledge wrote: On Fri, May 06, 2011 at 11:50:34AM -0400, Chet Ramey wrote: Eric suggested %q, and that works to a certain degree, but you can also use printf '"%s" ' "${vals[@]}" ; echo and get the double-quoting you want. Fa

Yet another quoting question

2011-05-06 Thread Steven W. Orr
4.0.35(1)-release (x86_64-redhat-linux-gnu) I have a bunch of arrays, and some of the arrays' values are null or might contain spaces. I wanted to write a routine to print out an array. It just takes the name of the array as an argument. Because some of the values of the array are null, whe

Re: Is this an IFS bug in getopts?

2011-04-26 Thread Steven W. Orr
On 4/26/2011 12:02 PM, DJ Mills wrote: On Tue, Apr 26, 2011 at 11:42 AM, Steven W. Orr wrote: GNU bash, version 4.0.35(1)-release (x86_64-redhat-linux-gnu) I ran a program that was supposed to die with an error message that said: Invalid format: example: 2.103.269.28-1-3 Instead, it died

Is this an IFS bug in getopts?

2011-04-26 Thread Steven W. Orr
GNU bash, version 4.0.35(1)-release (x86_64-redhat-linux-gnu) I ran a program that was supposed to die with an error message that said: Invalid format: example: 2.103.269.28-1-3 Instead, it died with: i -- Invalid format: example: 2.103.269.28-1-3 I traced the problem back to a call to getopt

Re: Question about arithmetic logic.

2011-04-18 Thread Steven W. Orr
Sorry to bother. I have no idea why it works now and did not before. Obvious case of cockpit error. :-( On 4/18/2011 10:30 AM, Steven W. Orr wrote: I happen to be running GNU bash, version 4.0.35(1)-release (x86_64-redhat-linux-gnu) I create an integer variable and assign it either a 0 or a

Re: Question about arithmetic logic.

2011-04-18 Thread Steven W. Orr
On 4/18/2011 10:40 AM, Greg Wooledge wrote: > On Mon, Apr 18, 2011 at 10:30:35AM -0400, Steven W. Orr wrote: >> ss=1 >> (( ss )) >> echo $?# Also says 1. Should this be 0 because it should be >> the >> # success result same as ((

Question about arithmetic logic.

2011-04-18 Thread Steven W. Orr
I happen to be running GNU bash, version 4.0.35(1)-release (x86_64-redhat-linux-gnu) I create an integer variable and assign it either a 0 or a 1. The arithmetic test always returns success regardless of value. For example: typeset -i ss=0 (( ss )) echo $? # Returns 1. Expected becau

Re: awk or sed

2011-04-06 Thread Steven W. Orr
On 4/5/2011 11:09 PM, ali hagigat wrote: I have a variable like this: var1=Makefile .xcompile /root/build/.config src/arch/i386/Makefile.inc means some words separated by spaces. I want to print each word on a separate line. I think I have to use "awk" or "sed" string processing tools. I wonder i

Re: bizarre trap behavior while reading a file

2011-03-29 Thread Steven W. Orr
On 3/29/2011 2:33 AM, Mart Frauenlob wrote: On 28.03.2011 18:03, tytus64 wrote: [...] trap "" HUP; cat $log_file | { while read line [...] useless use of cat! while read ... < file no need for a subshell actually (introducted by the pipe). I'm a big opponent of useless cats, but I ha

Re: How to safely pipe output to tee?

2011-03-07 Thread Steven W. Orr
On 3/7/2011 2:02 PM, Micah Cowan wrote: (03/07/2011 10:31 AM), Steven W. Orr wrote: I want to compute a command string which will end up in foo. Then I want to run that command and cause stdout and stderr to be piped to tee for safe keeping while it also goes to the screen. After the command

How to safely pipe output to tee?

2011-03-07 Thread Steven W. Orr
I want to compute a command string which will end up in foo. Then I want to run that command and cause stdout and stderr to be piped to tee for safe keeping while it also goes to the screen. After the command finishes, I need tee to exit. It sounds easy, but it's not. eval "$foo" 2>&1 | tee

Re: Problem with how to assign an array

2011-02-25 Thread Steven W. Orr
On 2/25/2011 4:22 AM, Andreas Schwab wrote: "Steven W. Orr" writes: 517> r=($(eval echo "\${${a_all[1]}[@]}")) If you use $(eval echo ...) you are almost always doing it wrong. eval "r=(\"\${${a_all[1]}[@]}\")" Andreas. Thanks. I changed thin

Re: Problem with how to assign an array

2011-02-24 Thread Steven W. Orr
Ok. Thanks for reading and responding. I thought I expressed myself but I see that I left too much out. I'll amplify below. On 2/24/2011 3:42 PM, Greg Wooledge wrote: On Thu, Feb 24, 2011 at 02:55:13PM -0500, Steven W. Orr wrote: I have three arrays a1=(aaa bbb ccc ddd) a2=(qqq www ee

Problem with how to assign an array

2011-02-24 Thread Steven W. Orr
I know how to assign a simple array. My problem is a bit harder. I have three arrays a1=(aaa bbb ccc ddd) a2=(qqq www eee rrr) a3=(fff ggg hhh) I then set a_all a_all=("${a1[*]}" "${a2[*]}" "${a3[*]}" Later on, I decide which element of a_all I really want. So with my new index calculated, I

Patterns of dynamic scoping and nested routines.

2011-02-21 Thread Steven W. Orr
It has been an exciting weekend for me. I studied the dynamic vs static scoping rules and I think I have a better handle on things, but I have a few questions. It seems that there's no reason why we are not allowed to write nested functions. Nested functions would not be visible to other functi

Re: typeset -r prevents local variable of same name.

2011-02-17 Thread Steven W. Orr
On 2/16/2011 11:08 PM, Clark J. Wang wrote: On Thu, Feb 17, 2011 at 11:13 AM, Chet Ramey wrote: If I declare a variable at the top scope using -r, it will prevent me from declaring a local copy in a subroutine. This problem happens in this version of bash as well as in bash4 under Fedora 14.

Problem with array initialization in typeset.

2005-05-27 Thread Steven W. Orr
Configuration Information [Automatically generated, do not change]: Machine: i386 OS: linux-gnu Compiler: i386-redhat-linux-gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-redhat-linux-gnu' -DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/s