General TC > Programming & Scripting - Unofficial

an elementary difficulty with bash scripting

(1/2) > >>

1) Only yesterday I tried to do my first Bash scripting with Tiny core v. 4.3. Even with such a simple for loop like the following:

for ((i=0; i<=100; i++))
echo "$i, "

This returns me with the error "line 2: syntax error: bad for loop variable". I can not understand. I am also new to scripting. Please someone may set me go ahead.

2) How can I find what Bash version is in use on Tiny core. Bash --Ver, Bash --version, sh --version etc. has not helped me in no way.

/bin/sh is ash, not bash.
If you really need bash, you must install the bash extension and use


That suffices me.

I also remember you as the first respondent to any of my posts on this forum. Thanx again.

Regarding your second question: I'm not sure what went wrong at your end, because it works for me as expected:

--- Code: ---tc@box:~$ bash --version
GNU bash, version 4.0.33(1)-release (i686-pc-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>

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

BTW, I've come to appreciate the fact that TC comes out of the box just with 'ash', as it encourages me to avoid any Bashisms. For me this is a better practice as it increases the chances that a shell script created for TC works without change in a different environment that might not have a BASH (or uses a different shell, e.g. 'ksh' in the case of UWIN or Solaris).

Furthermore, apart from the alternative shown in the page referenced above (i.e. a 'while' loop with a variable increment inside the loop) you could use for i in $( seq 0 100 ) as a replacement for your first line in your code snippet. This would be another way to avoid the need to install 'bash.tcz'.


1) My question clearly indicated that I was unaware of the existence of bash on my computer, which gerald_clark so nicely caught me. He even guided me to change the first line of my script, otherwise I would be returning here complaining once more. So with bash lacking on my computer, there was no question of getting its version. Once bash.tcz was 'installed", bash --version on my computer gives same results as it gives on your side. It is OK.

2) Thanks for the alternate for loop you have suggested me. At this stage of learning I can appreciate everything said to me. Also I am reading articles on shell scripting.

3) Since I am new to scripting at all, so would you or others really strongly suggest me that I take ash rather than bash ? I have just begun, and it is easy to change the shell, rather than it may be late later on. Or are the differences meagre, and can be overcome with ease even later on ?

4) What is the guarantee every system will have ash ? Some may be having bash. II will read about "Bashisms" later on.

Thanks all.


[0] Message Index

[#] Next page

Go to full version