Can You Upgrade Bash In Puppy Linux 5.4.3?

Booting, installing, newbie
Post Reply
Message
Author
Gnuxo
Posts: 365
Joined: Thu 09 Feb 2012, 19:01

Can You Upgrade Bash In Puppy Linux 5.4.3?

#1 Post by Gnuxo »

I've been trying to learn some Bash, and practicing if and then statements by writing a few newbie scripts but I keep getting syntax errors on almost everything I try.

I did a version check on Bash and found out that it's version 3.00 and that might explain why it's not responding to some of my bash commands.

Can Bash be updated? Or is there a workaround?

User avatar
Semme
Posts: 8399
Joined: Sun 07 Aug 2011, 20:07
Location: World_Hub

#2 Post by Semme »

Sure (PPM). While an example error would've helped, you probably want coreutils. Check if it's installed..

Gnuxo
Posts: 365
Joined: Thu 09 Feb 2012, 19:01

#3 Post by Gnuxo »

Coreutils is actually installed.

...and the example isn't very long. Just a little joke bash script I tried writing.

#!/bin/bash
clear
echo 'Say Please'
read word

clear
if [ ${word,,} = "please" ]
then
echo 'Thank you.'
fi

In that instance, line 7 ${word,,} comes up as a bad substitution error.

I couldn't understand why. And then I guessed that maybe the version of Bash is too old.

User avatar
Semme
Posts: 8399
Joined: Sun 07 Aug 2011, 20:07
Location: World_Hub

#4 Post by Semme »

I doubt the bash version's your problem. It's understanding, and you need help.

Saying you run frugal, I suppose you could <IF you really needed to> upgrade..

Code: Select all

GNU bash, version 4.2.24(1)-release-(i686-pc-linux-gnu)
Page search *read* for examples >> http://tldp.org/LDP/abs/html/

As far as coreutils, you have a version of it.

If GNU was installed, you'd be able to: which unlink and find it.

Send Flash a pm- have'm move this thread to Programming.

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#5 Post by SFR »

Gnuxo wrote:In that instance, line 7 ${word,,} comes up as a bad substitution error.

I couldn't understand why. And then I guessed that maybe the version of Bash is too old.
Indeed: ,, (convert to lowercase) is Bash 4 specific. To make it compatibile with Bash 3, you can use, for instance:

Code: Select all

if [ "`echo ${word} | tr [:upper:] [:lower:]`" = "please" ] 
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
Semme
Posts: 8399
Joined: Sun 07 Aug 2011, 20:07
Location: World_Hub

#6 Post by Semme »

Ah.. WHO :wink: I was hoping would post! Me? I'd never have guessed..

Gnuxo
Posts: 365
Joined: Thu 09 Feb 2012, 19:01

#7 Post by Gnuxo »

I'm still getting strange errors.

Does puppy even come with tr? I heard that some stripped down systems don't come with it.

edit: Nevermind. It works. Thank you very much for the help.

Post Reply