doing simple math in bash :: prb with leading zero

2009-09-01 Thread ken
Doing very simple math in bash fails if a number begins with a zero (0). The short script below illustrates the problem: --- begin #!/bin/bash #Testing number decrement because I ran into an errors #e.g., lastmo=$((${lastmo}-1)) returns error: # 09:

Re: bash 'let' can give error

2010-12-10 Thread Ken Irving
METIC EVALUATION above). If the last arg evaluates to 0, let returns 1; 0 is returned otherwise. Ken

Re: Problem with how to assign an array

2011-02-24 Thread Ken Irving
y name?) > Do it correctly: > > imadev:~$ unset a1 a2 big; a1=(a b '' c) a2=(d e f '') > imadev:~$ big=("${a1[@]}" "${a2[@]}") > imadev:~$ printf "<%s> " "${big[@]}"; echo > <> <> > > > I coul

Re: Problem with open and rm

2011-03-16 Thread Ken Irving
terminal) but > unfortunately the temporary file is left lying around. > > My two questions are: > Why? Assuming open doesn't somehow block, the script is probably working and removing the file just after open is invoked. > How can I change the script so that I can both view the file and have > it removed? Adding sleep 30 before rm ought to leave it around for a while. Ken

Re: Syntax Question...

2011-08-16 Thread Ken Irving
er if you can help by identifying where it might be done in the code. Ranting, inferring that people have 'little minds', aren't good or skilled programmers, etc., does little to make things better. Excessive verbosity, lingo, abbrevs, etc., don't help either. ;-) Ken

Re: Syntax Question...

2011-08-16 Thread Ken Irving
On Tue, Aug 16, 2011 at 03:41:19PM -0700, Linda Walsh wrote: > Ken Irving wrote: > >It seems to me that there are real bugs in applying set -e that can only > >be fixed by handling more special cases in the bash code,and those cases > >may vary for different scripts. &g

Re: Syntax Question...

2011-08-18 Thread Ken Irving
sion. As noted, you're being fooled by not quoting the variable, which is expanded in the echo and not in the <<< operation. $ rm *.x $ touch foo.x bar.x $ read a <<< *.x $ echo "$a" *.x $ echo $a bar.x foo.x Ken

Re: typeset -p on an empty integer variable is an error. (plus -v test w/ array elements)

2013-01-14 Thread Ken Irving
rn status is that of the last command executed in the function body. ... and similarly for exit: exit [n] ... If n is omitted, the exit status is that of the last command executed. ... Ken

Re: eval doesn't close file descriptor?

2013-02-12 Thread Ken Irving
for bidirectional data transfer between two independent data channels. Each of these data channels may be a file, pipe, device..., a socket..., a file descriptor (stdin etc.) ... Just a thought. Ken

Re: feature request: file_not_found_handle()

2013-08-14 Thread Ken Irving
est.types: No such file or directory It'd be great to have this fixed, or to have a file_not_found_handle(). But given that the first entry on a command line pretty much has to be a command, I'm not sure it makes sense to invoke file_not_found_handle() in this case, or whether it might be confusing as to when it gets invoked. Ken

Re: feature request: file_not_found_handle()

2013-08-18 Thread Ken Irving
ut this. I have a github project for it, but have not updated the documentation for quite a while, https://github.com/kirv/thinobject I'm not sure where an appropriate place to discuss the general topic would be, but at least the subject topic seems appropriate for bash-bug, whether as a bug or feature request. Ken

Re: feature request: file_not_found_handle()

2013-08-18 Thread Ken Irving
ternative is, as now, not being able to use tab-completion easily to reach an object, or having to edit the slashes out of the command, so really just more typing. A simple workaround is to tab-complete to cd into an object (directory), at which point method calls are local, no slashes, and the command-not-found hook is fired. Thanks for considering it at least! Ken

Re: feature request: file_not_found_handle()

2013-08-18 Thread Ken Irving
ce command and how it handles its arguments. We want the attempted command, e.g., lib/font/fontname.ttf, once it fails bash's attempts to execute it, to be passed to an alternative shell so it can have a go. In my system the handler would try to resolve lib/font/fontname as an object and ttf as a method, or maybe lib/font/fontname.ttf as the object and 'default' as the method. Ken

Re: feature request: file_not_found_handle()

2013-08-21 Thread Ken Irving
st a bash script, no tricks. On the command line, with the command-not-found hook, I'd omit the tob and let it be called implicitly, for convenience. I think this use is orthogonal to bash, and not in conflict with it. Ken > > > RR > > On 08/19/2013 10:29 PM, Andreas G

Re: feature request: file_not_found_handle()

2013-08-21 Thread Ken Irving
On Wed, Aug 21, 2013 at 08:10:50AM -0400, Greg Wooledge wrote: > On Wed, Aug 21, 2013 at 02:22:24AM -0800, Ken Irving wrote: > > $ cat $(ambler.method dispatch) > > #!/bin/bash > > method=$1 && shift > > test -n "$method" || exit >

Re: feature request: file_not_found_handle()

2013-08-21 Thread Ken Irving
7;re in need of the feature, implement it. > Otherwise, you're asking too much IMHO. I did send such a patch several years ago, and haven't brought the issue up since then. The OP's suggestion/request was somewhat different than what I had come up with, and is probably a better idea anyway, so yes, I probably should submit a patch for this feature. Thanks, Ken

feature request: apply parameter expansions to array keys

2013-12-15 Thread Ken Irving
not running the latest bash: $ bash --version GNU bash, version 4.2.37(1)-release (i486-pc-linux-gnu) Ken

Re: Feature request - ganged file test switches

2014-08-13 Thread Ken Irving
n . . . I thought that && could be used reliably within the [[ ]] construct, including short-circuiting the tests, so this could be: if [[ -d foo && -r foo && -x foo ]] ; then . . . I don't see how the bundled switces could be ambiguous, so must be missing something. Ken

bash script in background gets interrupted if carriage return is hit...

2007-10-12 Thread Ken Failbus
r terminal keys getting mis-represented. Regards, Ken

RE: bash script in background gets interrupted if carriage return is hit...

2007-10-15 Thread Ken Failbus
Hi Chet, I was able to solve the problem. By uncommenting a line in our script that was setting a "set -m" for Solaris platform I was able to resolve this issue. Thanks to everyone for looking into this one and advising. Regards, Ken -Original Message- From: Chet Ramey [mai

bash -n doesn't seem to catch all syntax errors...

2007-10-15 Thread Ken Failbus
o check for syntax errors. Regards, Ken ### example code p=hello e=world If [ p != $e ];then echo "not equal" else echo "equals" fi

RE: bash -n doesn't seem to catch all syntax errors...

2007-10-16 Thread Ken Failbus
with a good bad example. That way I would be heading in the right direction. Ken -Original Message- From: Stephane Chazelas [mailto:[EMAIL PROTECTED] Sent: Tue 10/16/2007 3:08 AM To: Ken Failbus Cc: bug-bash@gnu.org Subject: Re: bash -n doesn't seem to catch all syntax errors...

RE: bash -n doesn't seem to catch all syntax errors...

2007-10-16 Thread Ken Failbus
m -f '/tmp/file.+([0-9])' + exit 0 But if "bash -n" is run it doesn't understands +([0-9}) bash -n /tmp/mydummy /tmp/mydummy: line 3: syntax error near unexpected token `/tmp/file.+([' /tmp/mydummy: line 3: `rm -f /tmp/file.+([0-9])' Can you provide insight into t

RE: bash -n doesn't seem to catch all syntax errors...

2007-10-16 Thread Ken Failbus
So how can bash script syntax be verified that includes shopt??? Is there more option on bash syntax command-line check that would make it identify this grammar??? Thanks for the quick reply. Regards, Ken -Original Message- From: Andreas Schwab [mailto:[EMAIL PROTECTED] Sent: Tuesday

RE: bash -n doesn't seem to catch all syntax errors...

2007-10-17 Thread Ken Failbus
Thanks for your reply. That would certainly help. Regards, Ken -Original Message- From: Chet Ramey [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 16, 2007 9:51 PM To: Ken Failbus Cc: Andreas Schwab; bug-bash@gnu.org; [EMAIL PROTECTED] Subject: Re: bash -n doesn't seem to catc

Re: [PATCH] command-not-found-handle

2008-04-09 Thread Ken Irving
, the command_not_found_handle function could perhaps reconstruct the full command in order to pass to the tob handler. I'm running debian stable and unstable systems, e.g., $ uname -a Linux hayes 2.6.18-4-686 #1 SMP Wed May 9 23:03:12 UTC 2007 i686 GNU/Linux Thanks for any thoughts, rid

Re: piping output is delayed

2008-09-28 Thread Ken Irving
how i can modify the > output buffer to stdout. Try comparing terminal settings on each platform, e.g., with stty -a, and look into any differences. Ken -- Ken Irving, [EMAIL PROTECTED], 907-474-6152 Water and Environmental Research Center Institute of Northern Engineering University of Alaska, Fairbanks

patch for bash 3.2 manpage parameter expansion operator summaries

2008-10-25 Thread Ken Irving
e smallest or largest prefix pattern. ${parameter%word} ${parameter%%word} Remove smallest or largest suffix pattern. ${parameter/pattern/string} Pattern substitution. Thanks, Ken $ cat ~/tmp/bash-manpage-fix

Re: "C-z bg" without the lurch

2008-11-25 Thread Ken Irving
ut lurching my CD burning job, even for a split second? It sounds like you're not running bash, you're running the cd burner application. Bash exec'd it like you asked it to and is no longer in the picture. If it supports C-Z, then maybe it can do what you want? -- Ken Irving

Re: command not found magic

2008-12-04 Thread Ken Irving
about it. It needs a small > > change in bash. > > This will be in bash-4.0, with some improvements. Another wish-list item for that would be to pass the complete argument list to the handler. The current patch for this (in debian, same as ubuntu) only provides the failed command na

Re: how to know if a command was successful on remote server

2008-12-10 Thread Ken Irving
! /bin/bash > > #how can i get a returned value from this ? > ssh [EMAIL PROTECTED] remotescript param >From ssh(1): ssh exits with the exit status of the remote command or with 255 if an error occurred. Ken -- Ken Irving

Re: command not found on remote server

2008-12-11 Thread Ken Irving
making the script stronger when in reality > they are making it more fragile. More fragile because they are then > fixing the script into the rigid framework of a particular system. > That is the case I am frowning upon. I've often used hard-coded paths, and appreciate your argument and re

Re: command not found magic

2009-01-12 Thread Ken Irving
ommand_not_found_handle"), change it here. */ -/* #define NOTFOUND_HOOK "command_not_found_handle" */ + default ("command_not_found_handler"), change it here. */ +/* #define NOTFOUND_HOOK "command_not_found_handler" */ -- Ken Irving, fn...@uaf.edu, 907-474-6152 Water and Environmental Research Center Institute of Northern Engineering University of Alaska, Fairbanks

Re: Feature Idea: Enhanced Tab Completion

2009-03-21 Thread Ken Irving
ab to see history entries that start with it. This sounds a lot like what you get with the reverse-search-history command, bound to control-r (C-r), a great feature indeed. Ken -- Ken Irving, fn...@uaf.edu, 907-474-6152 Water and Environmental Research Center Institute of Northern Engineering University of Alaska, Fairbanks

Re: Bash script file naming problem?

2009-07-25 Thread Ken Irving
a command will be resolved. If you type: which script you'll likely see something other than what you're expecting. Ken -- Ken Irving, fn...@uaf.edu Water and Environmental Research Center Institute of Northern Engineering University of Alaska, Fairbanks

bash documentation error

2009-09-11 Thread Ken Nellis
Dear Bug-Bash: I found an error in your online bash documentation at [1]http://www.gnu.org/software/bash/manual/bashref.html In the [2]Conditional = Constructions (§3.2.4.2) section under the “case” command , the second paragraph start= s out: Each clau= se must be terminat

Re: qwerty

2009-11-11 Thread Ken Irving
'm using BASH_VERSION 3.2.39, so please forgive me if this issue are > already fixed There's nothing to fix. It might help if you provide some markers in your test patterns so you can see where each argument begins and ends, e.g., $ printf "(%d) {%s}\n" 1 ok - (1)

Re: Command substitution reduce spaces even in strings

2009-12-08 Thread Ken Irving
hort example: > > $ echo $(echo "'alfa beta'") > 'alfa beta' > > Instead of 'alfa beta' with double space. > > Repeat-By: > [Describe the sequence of events that causes the problem > to occur.] > > > $ echo $(echo "'alfa beta'") > 'alfa beta' > > Instead of 'alfa beta' with double space. $ echo "$(echo "'alfa beta'")" 'alfa beta' -- Ken Irving, ken.irv...@alaska.edu

Re: have bg, fg, but lack stop

2009-12-21 Thread Ken Irving
t; $ stop %1 > like command. kill %1 works for me. I've puzzled over this before, and I think part of the trouble may be that 'jobspec' is not defined in bash(1) (v 3.29). Ken > > OK, I suppose I can use > > $ kill -s SIGSTOP %1 > $ > [1]+ Stopped

Re: have bg, fg, but lack stop

2009-12-21 Thread Ken Irving
On Sat, Dec 19, 2009 at 05:48:44PM -0900, Ken Irving wrote: > kill %1 works for me. I've puzzled over this before, and I think part of the > trouble may be that 'jobspec' is not defined in bash(1) (v 3.29). Ok, I misunderstood the issue, stop vs kill. Ken -- ken.irv...@alaska.edu

command_not_found_handle not called if "command" includes a slash

2009-12-26 Thread Ken Irving
Configuration Information [Automatically generated, do not change]: Machine: i486 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='ba

Re: command_not_found_handle not called if "command" includes a slash

2009-12-28 Thread Ken Irving
On Sat, Dec 26, 2009 at 12:54:47PM -0900, Ken Irving wrote: > Description: > I'm not sure this is a bug, but I notice that the > command_not_found_handle function is not called if the "command" has a > slash in it. I can't find anywhere in the bash sou

Re: command_not_found_handle not called if "command" includes a slash

2009-12-29 Thread Ken Irving
On Mon, Dec 28, 2009 at 03:24:33PM -0900, Ken Irving wrote: > On Sat, Dec 26, 2009 at 12:54:47PM -0900, Ken Irving wrote: > > Description: > > I'm not sure this is a bug, but I notice that the > > command_not_found_handle function is not called if the "com

Re: command_not_found_handle not called if "command" includes a slash

2009-12-29 Thread Ken Irving
On Tue, Dec 29, 2009 at 10:40:04PM +0100, Jan Schampera wrote: > Ken Irving schrieb: > > >> This patch is not sufficient, as it leaves the error message, but it > >> does call the hook function in the problem cases: > > I'm just not sure if it makes

Re: command_not_found_handle not called if "command" includes a slash

2009-12-29 Thread Ken Irving
On Tue, Dec 29, 2009 at 12:33:25PM -0900, Ken Irving wrote: > On Mon, Dec 28, 2009 at 03:24:33PM -0900, Ken Irving wrote: > > On Sat, Dec 26, 2009 at 12:54:47PM -0900, Ken Irving wrote: > > > Description: > > > I'm not sure this

Re: $(pwd) != $(/bin/pwd)

2010-01-05 Thread Ken Irving
On Tue, Jan 05, 2010 at 08:23:39PM +0100, Andreas Schwab wrote: > Greg Wooledge writes: > > > On Mon, Jan 04, 2010 at 01:25:50PM +, Stephane CHAZELAS wrote: > >> >> da...@thinkpad ~/foo $ echo $PWD > >> >> /home/darkk/foo > > > >> Well, if I read > >> http://www.opengroup.org/onlinepubs/96999

Re: Variable getopts lost

2010-02-23 Thread Ken Irving
s to use the -n or -z test operators and to *quote the variable expansion*, e.g., if [ -z "$LSEITE" ]; then ... Unquoted variables expand to nothing, and are evaluated as such. Perhaps there are other such cases in your script? Ken

Re: Bash manual - interactive shell definition

2010-03-12 Thread Ken Irving
ified, without specifying the > -c option, and whose input and error output are both connected to terminals > (as determined by isatty(3)), or one started with the -i option. " > > be any more confusing? Is seems pretty clearly stated to me. Ken

Re: Bash manual - interactive shell definition

2010-03-12 Thread Ken Irving
On Fri, Mar 12, 2010 at 09:16:05AM +, Marc Herbert wrote: > >> Could this sentence: > >> > >> "An interactive shell is one started without non-option arguments, > >> unless -sis specified, without specifying the > >> -c option, and whose input and error output are both connected to terminals >

Re: Bash manual - interactive shell definition

2010-03-12 Thread Ken Irving
On Fri, Mar 12, 2010 at 12:50:26AM -0900, Ken Irving wrote: > On Fri, Mar 12, 2010 at 09:16:05AM +, Marc Herbert wrote: > > >> Could this sentence: > > >> > > >> "An interactive shell is one started without non-option arguments, > > >>

Re: Bash manual - interactive shell definition

2010-03-12 Thread Ken Irving
On Fri, Mar 12, 2010 at 11:57:41AM +0200, Pierre Gaston wrote: > On Fri, Mar 12, 2010 at 11:50 AM, Ken Irving wrote: > > > On Fri, Mar 12, 2010 at 09:16:05AM +, Marc Herbert wrote: > > > >> Could this sentence: > > > >> > > > >>

Re: Standard .bashrc needs a minor fix

2010-05-08 Thread Ken Irving
biguous, possibly suggesting that PS1 should also be checked to test for an interactive shell. This is apparently not the case, judging by this and other responses in this thread. I'm not sure how to reword it, but if testing for i in $- is sufficient then this might be clarified. Ken -- ken.irv...@alaska.edu

Re: function grammar

2010-07-18 Thread Ken Irving
... Shell Function Definitions ... [ function ] name () compound-command [redirection] and do not see the version you show without the parens. $ function good_dir() [[ -n $1 && -d $1 && -r $1 && -x $1 ]] $ good_dir; echo $? 1 $ good_dir /tmp; echo $? 0 Ken

Re: function grammar

2010-07-19 Thread Ken Irving
On Mon, Jul 19, 2010 at 10:46:30AM +0200, Bernd Eggink wrote: > Am 19.07.2010 08:30, schrieb Ken Irving: > >On Sun, Jul 18, 2010 at 11:53:02AM -0700, Linda Walsh wrote: > >> > >>from man bash, to define a function use; > >> > >>"function" &qu

Re: Bash style of if-then-else?

2010-09-23 Thread Ken Irving
; [ -f "$file" ] && { > do_something_0 > do_something_1 > } While we're talking about style... I prefer using 'test' rather than '[..]' as it seems to me to be more readable. test -f "$file" && do_something test -f "$file" && { do_something_0 do_something_1 } if test -f $file; then do something else do something else fi Are there actual advantages for [] over test? I guess the former uses one less byte than the latter. Ken

Re: asking for a better way to implement this

2010-09-26 Thread Ken Irving
done } A few points: Since you don't quote $@ there's probably no reason to quote $path. Your RMO will have options concatenated with no space between them. Your sed 's///g' might misbehave, e.g., xrm /tmp/home/tmp. The bash % expansion only operates on the last pattern. The -e option to sed seems to serve no purpose. I'm guessing your $(which rm) is intended to avoid calling rm(), but maybe \rm would do the same thing? No, that still calls the function... I'm not sure how to do that. This is the bug-bash list, maybe not the best place for this kind of thing... Ken

Re: pathname expansion part two

2010-10-15 Thread Ken Irving
$ echo foo /usrz* foo /usrz* I guess this makes sense, since just about all characters can be used in filenames, but I always need to check for this case, e.g., in for loops. Ken

Error in Bash-3.0 Makefile

2005-04-26 Thread Ken Kassing
27; ./mksyntax${EXEEXT} -o $@' After making these changes to the Makefile, the compile completed successfully. Thanks Ken Kassing [EMAIL PROTECTED] ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash

anomalous behaviour of ls command

2018-01-30 Thread ken young
Please find enclosed bashbug file. From: knoppi To: bug-bash@gnu.org,b...@packages.debian.org Subject: [behaviour of ls] Configuration Information [Automatically generated, do not change]: Machine: i686 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' -DC

bash doesn't compile when configured with --disable-bang-history

2019-07-17 Thread Ken Partridge
Configuration Information [Automatically generated, do not change]: Machine: arm OS: linux-gnu Compiler: gcc Compilation CFLAGS: -g -O2 -Wno-parentheses -Wno-format-security uname output: Linux 192.168.0.201 3.8.13 #1 SMP Thu Sep 12 10:27:06 CEST 2013 ar Machine Type: arm-unknown-linux-gnu Bash Ve

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

2015-02-09 Thread Ken Irving
On Mon, Feb 09, 2015 at 09:00:12PM +, Cheng Rk wrote: > > To bug-bash@gnu.org: > > According this documentation `help test`, I am expecting it should > return false on anything other than a regular file, > > -f FILETrue if file exists and is a regular file. > > but why it returned t

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

2015-10-19 Thread Ken Irving
ed pipes (FIFOs) or the /dev/fd method of naming open files. ... The section goes right into what seems like implementation details, and the use of it is only mentioned in the fourth sentence or so. Ken

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

2015-10-19 Thread Ken Irving
{ split : "some:colon:separated:words" ... } The V seen by split() (but alas, not declared within it) is a distinct variable for foo() and bar(). baz() would cause a global V to be defined implicitly (from within split()), which I'd tend to avoid. Ken

Re: Only one Friday 13th coming in 2016

2015-12-22 Thread Ken Irving
On Tue, Dec 22, 2015 at 04:04:16AM +0100, Ángel González wrote: > Bill Duncan wrote: > > Remember that while there are 14 patterns of years, leap years don't > > impact Friday the 13th for January/February.. > > > > This isn't an exhaustive analysis, but a quick check for 300 years > > didn't show

Why I love bash scripting?

2015-12-20 Thread ken . w . martin
Please copy the following to a file test.sh #!/bin/bash rx='(wlan)(1)' if [[ 'wlan1' =~ $rx ]]; then echo 'if returned 0' echo ${BASH_REMATCH[0]} echo ${BASH_REMATCH[1]} echo ${BASH_REMATCH[2]} echo ${#BASH_REMATCH}