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:
METIC EVALUATION above). If the last arg evaluates to 0, let
returns 1; 0 is returned otherwise.
Ken
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
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
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
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
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
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
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
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
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
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
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
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
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
>
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
not running the latest bash:
$ bash --version
GNU bash, version 4.2.37(1)-release (i486-pc-linux-gnu)
Ken
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
r
terminal keys getting mis-represented.
Regards,
Ken
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
o check for
syntax errors.
Regards,
Ken
### example code
p=hello
e=world
If [ p != $e ];then
echo "not equal"
else
echo "equals"
fi
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...
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
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
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
, 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
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
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
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
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
! /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
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
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
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
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
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
'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)
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
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
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
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
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
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
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
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
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
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
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
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
>
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,
> > >>
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:
> > > >>
> > > >>
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
...
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
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
; [ -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
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
$ 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
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
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
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
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
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
{
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
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
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}
65 matches
Mail list logo