Bash-4 breaks $() syntax on FreeBSD

2009-03-12 Thread Gerard
I just installed Bash-4 via the FreeBSD ports system. The installation
went fine. However, all of my Bash scripts that use the $()
syntax now fail with this error message:

syntax error near unexpected ')'

I have modified some of the scripts to use the older "`" tic method;
however, that is not really feasible with all of the scripts. How can
I correct this problem?

-- 
Gerard
ger...@seibercom.net


signature.asc
Description: PGP signature


Re: Bash-4 breaks $() syntax on FreeBSD

2009-03-12 Thread Gerard
On Thu, 12 Mar 2009 16:17:45 -0400
Chet Ramey  wrote:

>Gerard wrote:
>> I just installed Bash-4 via the FreeBSD ports system. The
>> installation went fine. However, all of my Bash scripts that use the
>> $() syntax now fail with this error message:
>> 
>> syntax error near unexpected ')'
>
>This isn't useful at all without an example I can use to reproduce the
>problem.
>
>Have you applied the bash-4.0 patches?  Several deal with command
>substitution parsing.
>
>Chet

Fair enough. I know that several users of FreeBSD are complaining all
ready and have switched back to Bash-3.x.

This is a short script, named "t.sh" that will produce the error
message:

#!/usr/bin/env bash

if $(which gpg2); then
   printf "gpg2 located"
fi
   
This is the error message:

./t.sh: command substitution: line 4: syntax error near unexpected
token `)' ./t.sh: command substitution: line 4: `which gpg2)'

Even something as simple as:

echo $(uname)

will produce the same error message.

This is the output of bash --version

GNU bash, version 4.0.10(1)-release (i386-portbld-freebsd6.3)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

If I can supply anything else, please let me know.

-- 
Gerard
ger...@seibercom.net


signature.asc
Description: PGP signature


Re: Bash-4 breaks $() syntax on FreeBSD

2009-03-12 Thread Gerard
On Thu, 12 Mar 2009 16:17:45 -0400
Chet Ramey  wrote:

[snip]

It is now believed that the problem has to do with Yacc on FreeBSD.
There is an experimental patch just issued that substitutes 'bison' for
'yacc'. It is being tested right now by some users.

I can supply you a copy of the FreeBSD Makefile patch for Bash-4.0 if
you want it.

-- 
Gerard
ger...@seibercom.net

If it pours before seven, it has rained by eleven.


signature.asc
Description: PGP signature


Re: new-style command substitution generates syntax error near ')'

2009-03-14 Thread Gerard
On Fri, Mar 13, 2009 at 10:58 PM, Chet Ramey  wrote:
> esum...@ualberta.ca wrote:
>
>> Machine Type: amd64-portbld-freebsd7.1
>>
>> Bash Version: 4.0
>> Patch Level: 10
>> Release Status: release
>>
>> Description:
>>       Bash reports syntax error near unexpected token `)' for
>>   new-style command substitution syntax, i.e., $(command)
>>   in interactive and non-interactive shells.
>>
>> Repeat-By:
>>       $ abc=$(ls)
>>   bash: command substitution: line 5: syntax error near unexpected token `)'
>>   bash: command substitution: line 5: `date)'
>
> This is due to a problem with the BSD yacc.  Rebuild the port using
> bison.
>
> Chet

An updated version of the port has all ready been committed. I tried
it and it works fine. Update your ports tree and it should be there.

-- 
Gerard
ger...@seibercom.net

No trees were injured in the creation of this email, but a large
number of electrons were terribly inconvenienced.




OT: Getting MySQL fields with embedded spaces into array

2009-10-28 Thread Gerard
I apologize for asking this here; however, I cannot seem to locate an
answer anywhere else.

I am writing a script that will use MySQL for a back end. I access MySQL
and store the results in arrays like this:

//snippet//

database: MyDataBase
table: MyTable
field: defaults

Now, I have populated the 'defaults' fields with the declare
statements that I will use in the script. They are entered similar to
this:
 
declare -a MSRBL_LIST

Now, I issue this from my bash script:

SQL_USER=user   # MySQL user
SQL_PASSWORD=secret # MySQL password
DB=MyDataBase   # MySQL data base name
HOST=127.0.0.1  # Server to connect to
NO_COLUMN_NAME="--skip-column-names"
COM_LINE="-u${SQL_USER} -p${SQL_PASSWORD} -h ${HOST} ${NO_COLUMN_NAME}"

table=MyTable

DECLARE_STATEMENTS=($(mysql ${COM_LINE} -i -e"use ${DB}; SELECT defaults FROM 
"${table}" WHERE 1;"))

for (( i=0;i<${#DECLARE_STATEMENTS[*]};i++)); do
echo  ${DECLARE_STATEMENTS[i]}
done

//end snippet//
 
This output is produced:

declare
-a
MSRBL_LIST

Obviously, that is not what I want. I have tried setting:

IFS=$( echo )

Prior to the invocation of the "DECLARE_STATEMENTS" statement; however,
that produced another error message and MySQL would not start.

I have been exploring different hacks to make this work. Perhaps
writing to a file and then using 'READ' to put the data into an array.
I was hoping that someone might have a working solution that I could
try. This problem only happens when the data stored in a MySQL field
contains embedded spaces or tabs. At least that is all that I am aware
of.

Thanks!

-- 
Gerard
ger...@seibercom.net

|===
|===
|===
|===
|

It isn't easy being the parent of a six-year-old.  However, it's a
pretty small price to pay for having somebody around the house who
understands computers.





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

2009-10-29 Thread Gerard
On Wed, 28 Oct 2009 08:38:07 -0400
Greg Wooledge  replied:

> > I have tried setting:
> > IFS=$( echo )  
> 
> $() removes all trailing newlines from the output of the command that
> it executes.  You're setting IFS to an empty string.  If you want to
> set IFS to a newline, use this:
> 
> IFS=$'\n'
> 
> Or this:
> 
> IFS='
> '

Are you sure? Using: IFS=$(echo) seems to set IFS to a newline here.
 
> > I have been exploring different hacks to make this work. Perhaps
> > writing to a file and then using 'READ' to put the data into an
> > array.  
> 
> 'read' is the most flexible way, though you don't need a temporary
> file to do this.  I have some more documentation on this approach
> here: http://mywiki.wooledge.org/BashFAQ/005

I got some great ideas from your page. However, I have not been able
to figure out how to save the results of the MySQL search, one that
might include spaces in the data, and inset it into an array without
creating a temp file and then using read to put it into an array.

Using a few suggestions from your page, I created this code snippet. It
works as I expect it to.

//snippet//

## Connect to the SQL server and store the contents of the query in an array

SIGS=$(mysql ${COM_LINE} -e"use ${DB}; SELECT sig from ${table} WHERE 
sig_file='0';")

## Set IFS = line feed or else the array will not load correctly
IFS=$(echo)

## Place the elements into a file
printf "%s\n" ${SIGS} > "Sigs.tmp"

## Restore the old IFS setting
IFS=${OLD_IFS}

## Place the elements into an array & clean any variables
unset i SIGS_ARRAY
while read -r; do SIGS_ARRAY[i++]=$REPLY; done < "Sigs.tmp"

//end snippet//

The array is now loaded and works in my script. I would love to
accomplish this without a temporary file; however, I have not found a
bullet proof method of doing it.

-- 
Gerard
ger...@seibercom.net

|===
|===
|===
|===
|

Q:How much does it cost to ride the Unibus?
A:2 bits.





operators available in bash versions

2009-11-30 Thread Gerard

I apologize for asking what is probably a dumb question, but where can
I find a definitive listing of what features are available in each
version of Bash.

For example, I only have access to Bash-4 on my system. I need to know
if " $(< " also works on Bash < 4. I also have a few questions
regarding array handling.

I am running FreeBSD-7.2 and installed Bash via ports.

-- 
Gerard
ger...@seibercom.net

|===
|===
|===
|===
|

Too much is not enough.





Re: operators available in bash versions

2009-12-01 Thread Gerard
On 1 Dec 2009 00:05:09 GMT
Allodoxaphobia Allodoxaphobia  replied:

> You can, doncha know, install ports into $HOME?
> Ergo, you could install bash 3.x and one or more earlier versions
> in $HOME/bin/ and test your scripts to your heart's content.
> 
> I found the install 'tricks' via Google, but I don't remember the 
> keywords I succeeded with beyond 'freebsd' and 'ports' now...
> 
> I successfully installed `alpine` in my FreeBSD shell account 
> at a time when the SysAdmin only had `pine` installed.

I have neither the time, inclination to install multiple versions; nor
the morbid fasination to observe what possible system damage may
eventually occur due to that enterprise. If I were writing a script
for eventual mass distribution, I would set up multiple stations, with
various operating systems, and shell versions and do a legitimate test.
I am actually writing for in-house use. I was simply inquiring for
information since I have one of the only two PCs in my organization that
have Bash-4 installed. The others all have various versions of Bash-3.
As each unit is replace, it is updated to the latest OS and software
versions. With the economy as it is, that is not about to happen any
time soon.


-- 
Gerard
ger...@seibercom.net

|===
|===
|===
|===
|

The opulence of the front office door varies
inversely with the fundamental solvency of the firm.





Re: BASH Command substitution

2009-12-17 Thread Gerard
On Thu, 17 Dec 2009 12:02:35 +0100
Zoltan Mate  articulated:

> this bugzilla isnt a forum for teaching people how to script bash.
> if you want further help, please ask on the bash mailing list, or the
> gentoo forums, or some other suitable location.

Where exactly is the "bash mailing list"?

-- 
Gerard
ger...@seibercom.net

|===
|===
|===
|===
|

Against stupidity the very gods Themselves contend in vain.


Friedrich von Schiller, "The Maid of Orleans", III, 6





Using 'eval'

2010-01-26 Thread Gerard
This is probably a dumb question; however, I have a question
regarding 'eval'.

I have seen the following statements:

eval $(foo -a -b)

and 

eval foo -a -b

Are they equal or are there differences between them, other than how
they are written out? Does it make any difference which syntax is used?

--
Gerard
ger...@seibercom.net

|===
|===
|===
|===
|

COLLEGE: The fountains of knowledge, where everyone goes to drink.





Redirection and old version of bash

2010-12-09 Thread Gerard Seibert
I have a script that I wrote and use successfully on FreeBSD with bash
version 4.1.9(0)-release (amd64-portbld-freebsd8.1). The script uses a
redirection "2>/dev/null" in several places. For some reason, that
does not seem to be working correctly under an old version of bash;
i.e. GNU bash, version 2.05.0(1)-release (sparc-sun-solaris2.9).

Specifically, this was occurring with rsync displaying messages of the
day, etc. This only happens under this version of Bash and apparently
only under Solaris.

I have managed to circumvent the problem; however, I was just
interested in knowing if anyone had heard of this before.

-- 
Gerard ✌
ger...@seibercom.net

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the Reply-To header.
__
Old MacDonald had an agricultural real estate tax abatement.



multi-dimensional arrays

2011-09-17 Thread Gerard Seibert
Just out of curiosity, are there any plans to make multi-dimensional
array variables available in future versions of Bash? I would find it
extremely useful.

-- 
Gerard ✌
ger...@seibercom.net

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the Reply-To header.
__
Life sucks, but death doesn't put out at all.

Thomas J. Kopp



Re: How to get filename completion without variable expansion?

2011-11-17 Thread Gerard Seibert
On Thu, 17 Nov 2011 11:22:27 -0500
Chet Ramey articulated:

> A version of that patch will appear in bash-4.3.

Just out of morbid curiosity, do you have an estimated date for
possible release of that new version?

-- 
Gerard ✌
ger...@seibercom.net

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the Reply-To header.
__
Reality is for people who can't deal with drugs.


Lily Tomlin



Re: '>;' redirection operator

2011-12-24 Thread Gerard Seibert
On Sat, 24 Dec 2011 15:08:34 -0600
Bill Gradwohl articulated:

> My original post was only to suggest that instead of more bells and
> whistles, talent should be applied towards the documentation of what
> is already there.

Bill, it is a well known fact that the developers of a product are
usually the worst at detailing and explaining it to an audience. That is
why professional authors who specialize in writing instruction manuals,
etcetera exist. The writers working in conjunction with the
developers/authors can write excellent documentation when given the
necessary resources. Unfortunately, these individuals do not work for
free. The irony is that the very basis of FOSS is that it precludes the
hiring of the talent required to product high quality documentation. Of
course, there is always the "man" page; which as many of us know is an
acronym for "much about nothing".

This is in no way an attempt to downplay Chet's or anyone elses efforts
at creating documentation for "Bash". It is just the nature of the
beast.

-- 
Gerard ✌
ger...@seibercom.net

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the Reply-To header.
__



Re: don't just seek to the next line if the script has been edited

2013-06-07 Thread Gerard Seibert
On Fri, 7 Jun 2013 10:19:44 -0400
Greg Wooledge articulated:

> Yes it can.  You're talking about adding a ridiculous amount of extra
> checking and performance penalty to try to avoid users shooting
> themselves in the foot *on Unix*.

The job of the OS is not to prevent a user from shooting themselves in
the foot, but rather to deliver the bullet as efficiently as possible.

-- 
Gerard ✌
ger...@seibercom.net

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the Reply-To header.
__




Re: bash auto complete malloc 'assertion botched' error

2010-10-09 Thread Gerard Seibert
On Fri, 8 Oct 2010 16:51:36 -0400
Fletcher Johnson  articulated:

> 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='bash'
> -DSHELL -DHAVE_CONFIG_H   -I.
> -I../bash -I../bash/include -I../bash/lib   -g -O2 -Wall
> uname output: Linux kiwi 2.6.31-22-generic #65-Ubuntu SMP Thu Sep 16
> 15:48:58 UTC 2010 i686 GNU/Linux
> Machine Type: i486-pc-linux-gnu
> 
> Bash Version: 4.0
> Patch Level: 33
> Release Status: release
> 
> Description:
> Typing the following in the shell produces...
> 
> fletc...@kiwi:~$ cd '\
> malloc: unknown:0: assertion botched
> free: start and end chunk sizes differ
> Aborting...
> 
> Repeat-By: typing cd '\ or ls "\ will reproduce the above bug

Using: GNU bash, version 4.1.7(2)-release (amd64-portbld-freebsd8.1)
does not seem to produce that error.

-- 
Gerard ✌
ger...@seibercom.net

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the Reply-To header.
__




Re: Bash handling of ENOENT on missing files and directories

2017-09-06 Thread Gerard Seibert
On Tue, 5 Sep 2017 10:57:20 -0400, Greg Wooledge stated:

>Keep following this slippery slope and you get Microsoft Windows error
>messages that say nothing useful at all.  "An error has occurred."

True, to a point. However, launching the "C:\WINDOWS\System32\eventvwr.exe"
application and then clicking on the Windows Log you want to investigate, gives
quite a bit of useful information. Perhaps, not as much as running a debugger,
but more than just a simple error code.

-- 
Gerard



Readline

2016-09-24 Thread Gerard Seibert
Out of morbid curiosity, has a date been set for the release of
"readline-7.0"? I know that there is an "RC" version in the wild right
now.

-- 
Gerard



Re: Disable microsoft telemetry

2019-10-20 Thread Gerard E. Seibert
On Fri, 18 Oct 2019 18:17:27 +0330, Behrooz Amoozad stated:
>I'm not sure if this even fits here, but it would be really nice if the
>default bashrc included DOTNET_CLI_TELEMETRY_OPTOUT='true'.
>Currently, After installing microsoft .net framework, it has telemetry
>enabled by default and it works at least once upon installation. It
>would be real nice if it didn't do that, anywhere, at all, not once.
>And ONLY you have the power to make this right.
>I don't know how many purists are left at gnu, I just hope there are
>enough left making decisions for bash.

I just read the
<https://docs.microsoft.com/en-us/dotnet/core/tools/telemetry> page,
and it appears that the information collected is both configurable and
used primarily to diagnose crashes. I don't find it overly intrusive
myself, but each to his own I suppose.

-- 
Gerard




pgpKrX7ZYAqcd.pgp
Description: OpenPGP digital signature