Re: Incorrect alias substitution

2009-02-24 Thread Paul Jarc
Vincent Lefevre wrote: > I get the following errors with bash 3.2.39 under Debian/unstable: > > bash -c 'alias a="echo OK >&2" > a > > /dev/null a' > bash: line 1: a: command not found > bash: line 2: a: command not found aliases aren't expanded by a non-interactive bash by default. If you do

Re: Pausing a bash script

2009-02-23 Thread Paul Jarc
DanSandbergUCONN wrote: > Hi All - If I want to write a script that uses ftp to transfer a file and > then, only after the file has been successfully transferred, I do something > else - how do I tell my script to wait until the ftp is finished before > doing the next command? Is that even possibl

Re: Help: Bash script that show you the last file created?

2009-02-15 Thread Paul Jarc
Mike Frysinger wrote: > the op wasnt asking for the time, they were asking for the last created file. > > and the ls man page talks how to sort by ctime. ctime is the time when the inode was last modified, not (necessarily) the time when the file was created. paul

Re: Help: Bash script that show you the last file created?

2009-02-15 Thread Paul Jarc
tal396 wrote: > Coz its could be find in alot of subdirs > like > /home/server/backups/local_backups/1-1-2009/server/mysql/1-1-2009.sql > /home/server/backups/local_backups/1-2-2009/server/mysql/1-2-2009.sql > /home/server/backups/local_backups/1-3-2009/server/mysql/1-3-2009.sql This will show th

Re: No tilde expansion right after a quotation

2009-02-15 Thread Paul Jarc
Jon Seymour wrote: > The manual specifies a rule for ${parameter:+word}, but not > ${parameter+word}. It's there, but easy to miss: In each of the cases below, word is subject to tilde expansion, parame- ter expansion, command substitution, and arithmetic expansion. When

Re: No tilde expansion right after a quotation

2009-02-15 Thread Paul Jarc
"Angel Tsankov" wrote: > How do you know that $# is always set? And what about $...@? To what values > are these parameters set outside any function? $# gives the number of positional parameters. If there aren't any positional parameters, then it's set to 0. In the man page, under PARAMETERS

Re: No tilde expansion right after a quotation

2009-02-15 Thread Paul Jarc
Jon Seymour wrote: > On Mon, Feb 16, 2009 at 10:22 AM, Paul Jarc wrote: >> CPATH=${CPATH:+$CPATH:}${#+~usr1/blah/blah} > > Out of interest, how does one derive that outcome from the documented > behaviour of bash? That is, which expansion rules are being invoked? It's $

Re: No tilde expansion right after a quotation

2009-02-15 Thread Paul Jarc
Jon Seymour wrote: > If the builtin echo fails it will be because the bash interpreter has > suffered a catastrophic failure of some kind [ e.g. run out of memory > ]. Once that has happened, all bets are off anyway. Probably true, but command substitution forks a separate process, so that can fa

Re: Option "-n" not working reliably and poorly documented

2009-02-11 Thread Paul Jarc
Jon Seymour wrote: > Not sure this is correct. The ] is parsed by the shell It's parsed by the [ command. That happens to be a builtin command, so yes, it is done by the shell, but it is not part of the grammar of the shell language. > This is why the -n option reports an error, since -n suppre

Re: Option "-n" not working reliably and poorly documented

2009-02-11 Thread Paul Jarc
Ronny Standtke wrote: > The "-n" option not seem to work. Example with a little stupid nonsense > script: > --- > ro...@ronny-desktop:/tmp$ cat test.sh > #!/bin/sh > if [ $blah == "test"] This sort of error can't be caught by -n, because it's part of a specific command, not the shell gram

Re: Declaring variables as local effects command status $?

2009-02-06 Thread Paul Jarc
Michael Rendell wrote: > local x=$( echo hi; exit 20); > ret=$? Here you're getting the exit status of "local" itself, which is 0. If you want the exit status of the command substitution, make that a separate command: local x x=$( echo hi; exit 20); paul

Re: Migrating from tcsh to bash (issues)

2009-02-03 Thread Paul Jarc
Simos wrote: > alias -- ../='cd ..' > alias -- .../='cd ../..' > alias -- /='cd /' You can do those as shell functions: ../() { cd ../; } .../() { cd ../..; } /() { cd /; } > 2. An issue with PS1 is that there is no \w or \W version that can > expand the ~. My aim is to get to show the full path

Re: truncating the path in the bash prompt?

2009-01-14 Thread Paul Jarc
Matthew Woehlke wrote: > Actually, a feature that would be REALLY helpful is a way to specify > certain directory strings that should be abbreviated. PS1='...$(mypath)...' mypath() { case $PWD/ in /usr/local/src/kde/svn/trunk/*) printf %s "${PWD/#\/usr\/local\/src\/kde\/svn\/trunk/\$s

Re: ${parameter+word} not documented in bash.info or bash(1)

2009-01-08 Thread Paul Jarc
"Martin Schwenke" wrote: > Neither bash.info or bash(1) documents parameter expansion of the > form: > > ${parameter+word} It's documented, but it's easy to miss. Just before the list of parameter expansion forms is this paragraph: In each of the cases below, word is subject to tilde e

Re: Can't execute file from command line

2009-01-03 Thread Paul Jarc
men8th wrote: > t...@ggeom:/usr/local/SunStudio12ml-linux-x86-200709-ii/sunstudio12/prod/bin$ > ./CC > bash: ./CC: No such file or directory > > However, the file clearly is there. Here is an extract of ls -l The problem could be that CC is a script, and the interpreter on its #! line does not ex

Re: $(grep anycommand anyfile) fail

2008-12-24 Thread Paul Jarc
BlackEnvil wrote: > [blacken...@space_star ~]$ cd $HOME; mkdir hello\ -world/; touch test; echo > "ls hello\ -world/" > test; $(grep ls test); > ls: invalid line width: orld/ Since $() is unquoted, it's simply split according to $IFS (at whitespace). If you want full shell-language parsing instea

Re: command not found on remote server

2008-12-11 Thread Paul Jarc
Bob Proulx wrote: > Also, using full paths is frowned upon. You mean invoking /directory/some-command directly instead of PATH=$PATH:/directory some-command ? It depends on the situation. If you think some-command is in /directory, but you want to allow for the possibility that it might be some

Re: command not found on remote server

2008-12-11 Thread Paul Jarc
Dolphin06 <[EMAIL PROTECTED]> wrote: > Can i do something like this : > ssh [EMAIL PROTECTED] export PATH=$PATH:/other path/ ; script param You'd have to quote the sequence of commands that should run on the remote host, so that the local bash and ssh see it as all one parameter: ssh [EMAIL PR

Re: Possible bug with respect to global variable within block of code when piping the output of later

2008-11-26 Thread Paul Jarc
Thiemo Kellner <[EMAIL PROTECTED]> wrote: > Maybe the piping converts the block implicitly to a subshell. Yes, it does. This is documented in the man page, under "Pipelines" in the "SHELL GRAMMAR" section, and in the FAQ, entry E4. paul

Re: [severe] access outside simlinked directory

2008-11-26 Thread Paul Jarc
AT-HE <[EMAIL PROTECTED]> wrote: > if you have a simlink pointing to a directory, chdir to that symlink > dir, and type something with '..', > you access the parent of real directory, not previous simlinked one. That's the kernel's doing, not bash's. When interpreting pathnames r

Re: Regular experssions are not working in 3.2.39 as in 3.1.17

2008-10-14 Thread Paul Jarc
[EMAIL PROTECTED] wrote: > regular expression are broken in 3.2.39 It's not broken; it's different. See entry E14 in the bash FAQ, and check out the compat31 option in shopt. paul

Re: errexit inconsistent behaviour with pipelines

2008-10-06 Thread Paul Jarc
Marcin Owsiany <[EMAIL PROTECTED]> wrote: > On Mon, Oct 06, 2008 at 09:22:30AM -0400, Chet Ramey wrote: >> This bug only occurs when errexit is enabled and the final element of a >> pipeline is a simple command that returns a non-zero exit status. > > Well, if the final element in the pipeline is a

Re: Keep bash output to one line

2008-09-25 Thread Paul Jarc
mikehershey32 <[EMAIL PROTECTED]> wrote: > Is there a way that i can make new output to the file overwrite the > old file content without stopping the program and restarting the script or > rotating the log file? { python -c ' import os import time while True: time.sleep(1) os.lseek(1, 0, 0)

Re: test -t

2008-09-07 Thread Paul Jarc
Chet Ramey <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: >> Is this a bug? >> $ t=test #bash builtin $ $t -t ' '; echo $? 0 > > Doesn't look like it: I think it is a bug, but libc may or may not hide it, depending on the strtol[l] implementation. SUS says: # If the subjec

Re: test -t

2008-09-03 Thread Paul Jarc
[EMAIL PROTECTED] wrote: > On (info "(coreutils)File type tests", and test(1) man page, we see > `-t FD' >True if FD is a file descriptor that is associated with a terminal. > > Well please mention what happens if FD is omitted: bash's "help test" explains this, if you know where to look

Re: Maximum limit of pipes in a single command ?

2008-08-28 Thread Paul Jarc
"Keshetti Mahesh" <[EMAIL PROTECTED]> wrote: > I followed the syntax properly. > But thats not the problem. Problem is how long can the concatenated > string can be ? If it's too long to fit in that command line, you could pass it this way: sed -f <(echo 's/old1/new1/;s/old2/new2/...') paul

Re: Maximum limit of pipes in a single command ?

2008-08-28 Thread Paul Jarc
"Keshetti Mahesh" <[EMAIL PROTECTED]> wrote: > I modified the script a little bit to concatenate all > "s//" using pipes and ran single 'sed' at the > end. But its not working. Thats why I want to know how many pipes > can I open through a single command. Also, I have tried > concatenated the repl

Re: CDPATH reports to stdout and even non-interactively

2008-08-15 Thread Paul Jarc
Geoff Kuenning <[EMAIL PROTECTED]> wrote: > BASH_ENVis the cracker's delight. Any setuid program that > invokes a Bash script, even indirectly, is completely > open to attack. Nope. Look at the -p option for set. BASH_ENV can be used to cause scripts to g

Re: function name bug ?

2008-07-30 Thread Paul Jarc
"christophe malvasio" <[EMAIL PROTECTED]> wrote: > cbz (){ echo "why 'cbz' not a valid function name ?";} > bash: syntax error near unexpected token `(' It works for me. What does "alias cbz" say for you? paul

Re: kill job vs. pid

2008-07-26 Thread Paul Jarc
Daniel Norton <[EMAIL PROTECTED]> wrote: > How do I tell bash to kill job 1, rather than pid 1 ? man bash, in the section JOB CONTROL: # There are a number of ways to refer to a job in the shell. The # character % introduces a job name. Job number n may be referred to # as %n. A job may also

Re: inconsistent treatment of backslash-bang

2008-07-23 Thread Paul Jarc
Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote: > Chet Ramey wrote: >> This is from the man page, in the QUOTING section: > > No idea about that. GNU project folks are well-known for deprecating man > pages. I go by the reference manual > . That

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

2008-07-22 Thread Paul Jarc
Richard Neill <[EMAIL PROTECTED]> wrote: > the aim is to parse the output of "ffmpeg -formats" to see whether > certain codecs are supported by that build. I'd use something like: while read line; do ... done < <(ffmpeg -formats 2>/dev/null) That puts ffmpeg into a subshell instead of read. p

Re: inconsistent treatment of backslash-bang

2008-07-20 Thread Paul Jarc
Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote: > It's not going to break any executable scripts, since it has already > been pointed out to me that history expansion doesn't happen in > scripts. History expansion doesn't happen in scripts *by default*, but it can be enabled explicitly. paul

Re: inconsistent treatment of backslash-bang

2008-07-20 Thread Paul Jarc
Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote: > Chet Ramey wrote: >> I already explained that bash follows csh as closely as possible >> in its history expansion implementation. > > Well, it doesn't: Sure it does: in your examples, bash tries history expansion in exactly the same cases as tcsh.

Re: inconsistent treatment of backslash-bang

2008-07-18 Thread Paul Jarc
Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote: > pk wrote: >> This is documented in man bash, and only happens in interactive shells (not >> scripts). > > I just tried putting my six cases into a script, and I get exactly the same > sort of output as interactively. How did you invoke the script?

Re: alias expansion with functions in non-interactive mode

2008-05-31 Thread Paul Jarc
Marco <[EMAIL PROTECTED]> wrote: >I couldn't find any information on it, but I'm noticing alias expansion >is not happening in non-interactive mode within a function with >expanded_aliases turned on. Is this a know problem, or am I missing >something?

Re: spaces in the shebang interpreter path

2008-05-11 Thread Paul Jarc
Felix Schwarz <[EMAIL PROTECTED]> wrote: > I'm not able to specify an interpreter in a shebang line if the path > to this interpreter contains spaces. It's actually the kernel that interprets that line, not bash. The historical behavior is that space separates the interpreter from

Re: function names which contain a 'dash' character

2008-05-09 Thread Paul Jarc
Jan Schampera <[EMAIL PROTECTED]> wrote: > Stephane Chazelas wrote: >> Note that bash didn't have to. POSIX allows a shell to accept >> any character in a function name, but it says one shouldn't use >> those in a POSIX script, which is different. > > I'm not a POSIX expert, and this is the SUS, bu

Re: for ... in ... do ignores escape characters

2008-04-17 Thread Paul Jarc
luiscolorado <[EMAIL PROTECTED]> wrote: > This is what I get when some file names have spaces: > > for i in `my-program` > do > echo $i > done > > It echoes the following: > > sony > apple > hewlett > packard Unquoted `` expansions are split into words using $IFS. So if you only want to split on

Re: Cursor misplaced while iterating history

2008-04-11 Thread Paul Jarc
"João Abecasis" <[EMAIL PROTECTED]> wrote: > $ PS1='\e[0;[EMAIL PROTECTED] \W]$i\[\e[m\]' Sorry, ignore the previous message - you're missing \[ before the first escape sequence. paul

Re: Cursor misplaced while iterating history

2008-04-11 Thread Paul Jarc
"João Abecasis" <[EMAIL PROTECTED]> wrote: > $ PS1='\e[0;[EMAIL PROTECTED] \W]$i\[\e[m\]' See entry E3 in the bash FAQ: http://tiswww.case.edu/php/chet/bash/FAQ paul

Re: shorthand attempt at 'basename file .ext'

2008-03-25 Thread Paul Jarc
Linda Walsh <[EMAIL PROTECTED]> wrote: > > echo "${{f##*/}%$ext}" (but: -bash: ${{f##*/}%$ext}: bad substitution) > > Do I need to use an intermediate variable Yes. Unfortunately, the expansion operators work directly on variables - not on arbitrary strings which may contain other expansions. p

Re: problems with 'read'ing from a pipe

2008-03-14 Thread Paul Jarc
"John Smith" <[EMAIL PROTECTED]> wrote: > echo foo | read VAR > echo $VAR See entry E4 in the bash FAQ: http://tiswww.case.edu/php/chet/bash/FAQ paul

Re: Which Bash

2008-02-24 Thread Paul Jarc
Charlse Darwin <[EMAIL PROTECTED]> wrote: > i.e. How do I get the latest to be the login shell? You could add "exec bash" as the last command in ~/.bash_profile. paul

Re: broken pipe

2008-02-13 Thread Paul Jarc
"Brian J. Murrell" <[EMAIL PROTECTED]> wrote: > It is a shame for this particular reason that head does not (perhaps as > an option) consume it's input after displaying the 20 lines. You can do that with sed: ... | sed '21,$d' paul

Re: tricky shell script question

2008-02-12 Thread Paul Jarc
"Erik-Jan Taal" <[EMAIL PROTECTED]> wrote: > Now watch the terminal where the script was still running. I would > expect no output to be given, as I assumed the script is read into memory > at startup and not during execution and this is what happens on most > systems. On one server however, the '

Re: capturing sub-expressions?

2008-01-29 Thread Paul Jarc
Linda Walsh <[EMAIL PROTECTED]> wrote: > p="-e -p 60 -x" > --- > That's why I wanted the capture -- to pick out the 60 -- where 60 represents > a positive integer. The space between the -p and the number is optional. It sounds like you're looking for getopt. paul

Re: matching !(patterns)

2008-01-29 Thread Paul Jarc
Linda Walsh <[EMAIL PROTECTED]> wrote: > The longest matching substring (because you use "/" to start the pattern, > yes?) No, !() normally uses the longest match, just like *, *(), and +(). >s="thomas rich george" > > Manpage says "!()" will match anything except one of the patterns. > > "

Re: capturing sub-expressions?

2008-01-29 Thread Paul Jarc
Bernd Eggink <[EMAIL PROTECTED]> wrote: > My impression is that the pattern lookup depends on whether or not a > !' is involved. If the pattern does not contain a '!', the shell looks > for matching substrings, from left to right. If it contains a '!', the > value as a whole is matched. It looks f

Re: capturing sub-expressions?

2008-01-29 Thread Paul Jarc
Linda Walsh <[EMAIL PROTECTED]> wrote: > In my copy of the man pages, Pattern matching is indented an extra > level making it look like it's under Pathname Expansion and only > applies there Pattern matching applies primarily to pathname expansion; other uses explicitly refer to its use there:

Re: Exit application with two function calls

2008-01-27 Thread Paul Jarc
Linda Walsh <[EMAIL PROTECTED]> wrote: > # *1 - using "-e" stops your script immediately on any error Not any error - only those from simple commands. The subtleties are subtle enough that I avoid -e, and use "&&" between all commands instead. paul

Re: unset strangely rejects certain function names eg fu~

2007-12-12 Thread Paul Jarc
[EMAIL PROTECTED] wrote: > $ unset fu~ > bash: unset: `fu~': not a valid identifier You can use "unset -f" to unset a function whose name doesn't fit the rules for variable names. paul

Re: Problem with pattern replacing when STRING is an expandable char

2007-12-12 Thread Paul Jarc
Heinz-Ado Arnolds <[EMAIL PROTECTED]> wrote: > a=111.1 > echo ${a//[0-9]/x} > > correctly gives "xxx.x", but > > echo ${a//[0-9]/*} > > gives a listing of files in current directory. Seems that the "*" > is expanded before replacing the pattern. No, it's expanded afterward,

Re: Disowned process hangs terminal during logout/exit

2007-12-05 Thread Paul Jarc
Jesse Molina <[EMAIL PROTECTED]> wrote: > Basically, on the two troubled systems, my interactive shell will > hang after I've disowned a process. On one other system, everything > works as expected. I expect that a disowned process should not hang > logout -- disowned means disowned. The termina

Re: problematic \r in msgid

2007-11-24 Thread Paul Jarc
Chet Ramey <[EMAIL PROTECTED]> wrote: > The idea is that malloc/free can be called at any time, by any piece > of code, regardless of the state of the terminal: raw, canonical, > whatever. The intent is that the cursor be placed at column 0 both > before and after printing the message, so it stand

Re: Problem with reading file and executing other stuffs?

2007-11-02 Thread Paul Jarc
Horinius <[EMAIL PROTECTED]> wrote: > Is there any pitfall using this solution of yours? You talked about > "regular file", what's that supposed to be? Text file vs binary file? No, just that it doesn't work for pipes, so the data you're reading has to be in a named file, not produced as the out

Re: try to open file descriptor for input with 'exec' fails

2007-11-02 Thread Paul Jarc
[EMAIL PROTECTED] wrote: > ./doit: line 29: exec: 3: not found > > This is the line where i try to open the file descriptor > for input: > exec ${fd}<$inf Try this: eval "exec ${fd}< "'"$inf"' And likewise, when closing the descriptor: eval "exec ${fd}>&-" paul

Re: Problem with reading file and executing other stuffs?

2007-11-02 Thread Paul Jarc
Horinius <[EMAIL PROTECTED]> wrote: > Paul Jarc wrote: >> Read entry E4 in the bash FAQ: >> http://tiswww.case.edu/php/chet/bash/FAQ > > I've read several times that section but I'm not sure how to use the IFS. IFS is only useful if you're splitting the

Re: Problem with reading file and executing other stuffs?

2007-11-01 Thread Paul Jarc
Horinius <[EMAIL PROTECTED]> wrote: > cat test.txt | > while read line Read entry E4 in the bash FAQ: http://tiswww.case.edu/php/chet/bash/FAQ paul

Re: Running commands from array in a child script

2007-10-26 Thread Paul Jarc
bengoavs <[EMAIL PROTECTED]> wrote: > CMDS=("ls -l > /tmp/log") > ~/child.sh "${CMDS[0]}" > > child.sh: > for i in "$@" > do > if [ "$i" ]; then > echo "$i" > $i Redirections and other special characters are not treated specially if they are produced by a va

Re: Evaluating a variable within a variable

2007-10-23 Thread Paul Jarc
TimtheEagle <[EMAIL PROTECTED]> wrote: > main_auth=7 > > f=main > t=auth > > ile=$f"_"$t > > echo $ile Either: echo "${!ile}" Or: eval "echo \"\$$ile\"" paul

Re: Multi-word matching in history expansion

2007-09-30 Thread Paul Jarc
The Wanderer <[EMAIL PROTECTED]> wrote: > !ls /h How about: ls /h paul

Re: Bash Prompt location

2007-09-21 Thread Paul Jarc
hirochiamaru <[EMAIL PROTECTED]> wrote: > I saw it on a screen shot once, but this gentlemen was able to put the bash > prompt at the bottom of his xterm window with out fill the top portion the > xterm window first. yes '' | head -n "$LINES" paul

Re: "[ -n ${emptyvariable} ]" returns success

2007-09-20 Thread Paul Jarc
[EMAIL PROTECTED] wrote: > foo= > [ -n ${foo} ] && echo true > > Prints "true". That's the correct behavior. > Should probably print an error, since after the command is > expanded there are only three arguments, so the final ] should > be interpreted as the ar

Re: PATH strange behaviour

2007-08-03 Thread Paul Jarc
"Jérémy Hervé" <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED]:/usr/bin# httpd -v > -bash: /usr/sbin/httpd: No such file or directory "hash -r" will fix that. See "help hash" and "man bash" for details. paul ___ Bug-bash mailing list Bug-bash@gnu.org

Re: Exit-on-error option does not work as expected

2007-07-17 Thread Paul Jarc
[EMAIL PROTECTED] wrote: > My claim is that in the attached script, the 'false' command should > *not* be considered to be a part of the && list. Nevertheless, it is. The current behavior is too well-entrenched to change it, so the most reliable way to get the behavior you want is

Re: Inconsistent regex matching with =~ between bash 3.1 and 3.2

2007-07-11 Thread Paul Jarc
Scott Carpenter <[EMAIL PROTECTED]> wrote: > V="one/two" > [[ ! $V =~ ^\.*/ ]] && echo not 3.1 will remove the backslash as part of basic string parsing, just as if this were not part of a [[ command, while 3.2 handles the arguments for [[ specially, and will keep the backslash as part of the rege

Re: Assigning variable value in right behalf of pipeline has no effect

2007-07-05 Thread Paul Jarc
[EMAIL PROTECTED] wrote: >> > XXX=10; { XXX=20; } | read; echo $XXX > > It's clear that 'read' is executed as an separate process and its > result (REPLY variable value) is lost but 'XXX=20' command is done by > the same process as 'XXX=10'. No, every element of a pipeline is executed in its own

Re: Assigning variable value in right behalf of pipeline has no effect

2007-07-05 Thread Paul Jarc
[EMAIL PROTECTED] wrote: > XXX=10; { XXX=20; } | read; echo $XXX > > XXX=10; { XXX=20; }; echo $XXX > > I suppose both of them should output '20' but the first one outputs > '10'. Is it feature of bug? This is normal. It's explained in entry E4 in the bash FAQ. paul _

Re: wrong logical evaluation of expressions involving true or false commands

2007-06-25 Thread Paul Jarc
Matthew Woehlke <[EMAIL PROTECTED]> wrote: > Stephane Chazelas wrote: >> [ -n "$foo" -a -n "$bar" ] >> is not the expression to test whether both "$foo" and "$bar" are >> non-empty, as it would fail for some specific values of $foo or >> $bar (try it when $foo contains "=" for instance). > > Huh? W

Re: Bash command completion when not connected to a terminal

2007-06-06 Thread Paul Jarc
raner <[EMAIL PROTECTED]> wrote: > The completion seems to work, but I do not receive the completed filename > from the shell's stdout. It's written to stderr, not stdout. paul ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/l

Re: variable lost when while loop piped

2007-06-02 Thread Paul Jarc
[EMAIL PROTECTED] wrote: > A variable set inside a while loop loses its value if > the while loop is piped to a command, e.g., sed. This is normal. Read entry E4 in the bash FAQ. paul ___ Bug-bash mailing list Bug-bash@gnu.org http://lis

Re: tracing inside functions

2007-05-31 Thread Paul Jarc
Nic James Ferrier <[EMAIL PROTECTED]> wrote: > Using bash 2.05, does anyone know of a way to get a trace of what's > happening inside a function? You can add "set -x" at the top of the function body. I don't know of any way to get a similar effect without editing the script. paul

Re: Pattern replacement inconsistency

2007-05-30 Thread Paul Jarc
Chet Ramey <[EMAIL PROTECTED]> wrote: > Anchored pattern matches that specify removing or replacing each match > don't make sense. The combination is meaningless. It seems meaningful to me, but since only one occurrence could match an anchored pattern, "every match" just means the same thing as "

Re: Timing an operation

2007-05-24 Thread Paul Jarc
Matthew_S <[EMAIL PROTECTED]> wrote: > Can i have something like; > > if > difference between dates <5seconds > echo fail > fi date1=`perl -e 'print time()'` ... date2=`perl -e 'print time()'` interval=`expr "$date2" - "$date1"` if test 5 -gt "$interval"; then echo fail fi On some systems, yo

Re: set function and special builtin set

2007-05-18 Thread Paul Jarc
Benno Schulenberg <[EMAIL PROTECTED]> wrote: > Andreas Schwab wrote: >>: >> >> If a simple command results in a command name and an optional >> list of arguments, [...] > > But set() is not a simple command

Re: Infinite loop and crash Linux via BASH command

2007-05-17 Thread Paul Jarc
[EMAIL PROTECTED] wrote: > I don't know by this means (perhaps anybody here with bigger > experiences to can explain us) this simple command creates a job in > background and in loop that quickly consome all the processing. Yes, because that's exactly what you're telling bash to do, if you run

Re: backwards menu-complete with shift+tab

2007-05-14 Thread Paul Jarc
<[EMAIL PROTECTED]> wrote: > Specifying the key combo shift+tab is not documented. Your terminal program probably doesn't distinguish tab from shift+tab. To check, try running od, and type tab, enter, shift+tab, enter, and see if od prints the same codes for both. paul ___

Re: Generating unique file names

2007-05-13 Thread Paul Jarc
matte <[EMAIL PROTECTED]> wrote: >The count would be sufficient, as each folder will always hold ONLY these >archives, and no hidden files. >Thus, my directory would be: >myArcName_1.tar.gz >myArcName_2.tar.gz >myArcName_3.tar.gz This will do it, starting the numbering at 0

Re: read 1 var in when executing command

2007-05-12 Thread Paul Jarc
jdh239 <[EMAIL PROTECTED]> wrote: > I would prefer, again, just to execute the command with the domain name > following Not sure how to do it. You can define the command as a shell function (see "Shell Function Definitions" in the man page under "SHELL GRAMMAR"). You can refer to the first a

Re: Characters aren't being properly escaped/evaluated in a Bash

2007-05-10 Thread Paul Jarc
[EMAIL PROTECTED] wrote: > The problem is that if I did this out of the box > like the following, it 'flattens' the list: > > Example: > for j in `cat $i`; do > echo $j > done > >

Re: How to remove a specific line in a file

2007-05-01 Thread Paul Jarc
Matthew Woehlke <[EMAIL PROTECTED]> wrote: > It seems like there should be a way to delete the first match in pure > sed, but I didn't figure it out in the few seconds testing I did. sed '/foo/{x;/^$/d;}' paul ___ Bug-bash mailing list Bug-bash@gnu.

Re: Bash arithmetic doesn't give error message on wrap.

2007-04-30 Thread Paul Jarc
Andreas Schwab <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] (Paul Jarc) writes: >> result=a*b; >> if (result/a!=b) { report overflow; } > > That won't work, since (signed integer) overflow is undefined in C. A > compiler is allowed to optimize the condition

Re: Bash arithmetic doesn't give error message on wrap.

2007-04-30 Thread Paul Jarc
Richard Neill <[EMAIL PROTECTED]> wrote: > I thought testing for overflow was quite simple? > Isn't it just a case of looking at the carry-bit, and seeing whether it > gets set? That's usually how it's done in assembly. In C, it's somewhat more compilcated. For example: result=a*b; if (result/a

Re: Bash arithmetic doesn't give error message on wrap.

2007-04-30 Thread Paul Jarc
[EMAIL PROTECTED] (Bob Proulx) wrote: > On some cpus the result is done one way and on others the result is > done a different way. It is in these cases where typically POSIX > would give up and declare it undefined behavior. Yes, and those are exactly the cases where a message would be helpful,

Re: Problem with array element assignment

2007-04-15 Thread Paul Jarc
homac <[EMAIL PROTECTED]> wrote: > cat test.txt | while read s l ; do Read entry E4 in the bash FAQ: http://tiswww.case.edu/php/chet/bash/FAQ paul ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash

Re: shouldn't prompt printing be smarter?

2007-04-01 Thread Paul Jarc
Francesco Montorsi <[EMAIL PROTECTED]> wrote: > why would you ever want to have the prompt printed at non-zero column of > the terminal? One possible reason: so you can know whether the previous command ended its output with a newline. Otherwise the output becomes slightly ambiguous. >> If you

Re: Syntax question

2007-03-24 Thread Paul Jarc
"Caleb Cushing" <[EMAIL PROTECTED]> wrote: > the line > FEATURES="parallel-fetch ccache distlocks"# userfetch userpriv usersandbox > > I was told my bug is not a bug because there was no space in between the "# > > putting a space does fix the problem but I can't recall that I've ever seen > any do

Re: parameter expansion malinterpretation

2007-03-08 Thread Paul Jarc
[EMAIL PROTECTED] wrote: > [EMAIL PROTECTED] ~ $ hello="hello"; echo ${hello:-1} Read entry E12 in the bash FAQ. paul ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash

Re: while read subcommand problem

2007-03-02 Thread Paul Jarc
Andreas Schwab <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] (Paul Jarc) writes: >> while ...; do var=...; done <> $(generate-input-for-while) >> EOT >> use "$var" > > This has the disadvantage that generator and consumer no longer run > co

Re: while read subcommand problem

2007-03-02 Thread Paul Jarc
Richard van der Leeden <[EMAIL PROTECTED]> wrote: > The examples in the FAQ do work for the their examples, but I can't figure > out a clean way to implement it with a while loop when reading in lines from > the output of a piped command(s). The redirection applied to "read" in those examples woul

Re: while read subcommand problem

2007-03-02 Thread Paul Jarc
rleeden <[EMAIL PROTECTED]> wrote: > NOTE: This is just an example, so I don't need alternatives for how I could > achieve the specifics shown above. I need to find a good solution where I > can do things with a file (whether it be with sed, awk, tail, head etc.) > then pipe it into a 'while read'

Re: /etc/bash.bashrc derivation and "misuses"

2007-02-25 Thread Paul Jarc
Chet Ramey <[EMAIL PROTECTED]> wrote: > In my opinion, if a system vendor chooses to enable that sort of > functionality (and many do, for all sorts of reasons), then they > need to add something to the documentation noting that. Could that be done automatically by ./configure when this is enabled

Re: Just created alias doesn't work in a string of commands

2007-02-08 Thread Paul Jarc
"Gurjeet Singh" <[EMAIL PROTECTED]> wrote: > 1$ cat setenv.sh > #!/bin/sh > > alias llrt='ls -lrt' ... > 5$ . ./setenv.sh && llrt && . ./unsetenv.sh > sh: llrt: command not found Aliases are expanded when a command is read, not when it is executed. The entire && chain of commands forms a single co

Re: reading the first colums of text file

2007-02-03 Thread Paul Jarc
"Brian J. Murrell" <[EMAIL PROTECTED]> wrote: > < <(cat $file) http://partmaps.org/era/unix/award.html paul ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash

Re: can't pass a response from bash script to an app's interactive dialog

2007-01-25 Thread Paul Jarc
snowcrash+bugbash <[EMAIL PROTECTED]> wrote: > CMD="$GPG --output revoke.txt --gen-revoke $ME" > > /usr/bin/expect -c "\ > spawn `$CMD`;\ > stty -echo;\ > expect 'Create a revocation certificate for this key? (y/N) ';\ > send 'y\n'" You have backticks around $CMD. That means bash will run t

Re: man page "-c" explanation clarity

2007-01-23 Thread Paul Jarc
"Paul A. Clarke" <[EMAIL PROTECTED]> wrote: > The man page states, for the "-c" option: >-c string If the -c option is present, then commands are read from > string. If there are arguments after the string, they are > assigned to the positional param

Re: long lines not wrapping correctly in Mac OS X

2007-01-17 Thread Paul Jarc
agl <[EMAIL PROTECTED]> wrote: > PS1=$'\[\e]2;\]\h\[\a\]\h:\w \u\$ ' Try this: PS1=$'\[\e]2;\h\a\]\h:\w \u\$ ' The first \h doesn't move the cursor position, so it should be kept within \[ and \] along with the escape sequences. paul ___ Bug-bash ma

Re: Quotes problem ?

2007-01-11 Thread Paul Jarc
Markos <[EMAIL PROTECTED]> wrote: > You said that line > cd $path > should be better with quotes to avoid problems with dir names containing > spaces, so did you mean this? > cd "$path" Yes. paul ___ Bug-bash mailing list Bug-bash@gnu.org http://li

Re: Quotes problem ?

2007-01-10 Thread Paul Jarc
Markos <[EMAIL PROTECTED]> wrote: > #Delete "logo_1.gif" string from every line in results_1, > #leaving only the path to prepare for "cd" step > > sed 's/logo_1.gif//' /tmp/results_1 >/tmp/results This would be more precisely expressed as: sed 's:/logo_1\.gif$:/:' /tmp/results_1 >/tmp/results If

  1   2   >