Backward compatibility issue with GNU bash, version 4.3.42(5)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Backward compatibility issue with GNU bash, version 4.3.42(5)
# 1  
Old 04-29-2017
Backward compatibility issue with GNU bash, version 4.3.42(5)

Hi,

I have made a snake game on below bash version. But it is not backward compatible. Can someone suggest a version which is most commonly used and
is backward compatible so that i can change my code and share again?
I have attached the game script. If someone can run it please also suggest improvements and new ideas

Code:
GNU bash, version 4.3.42(5)-release (x86_64-pc-msys)



Thanks,
Amit

Last edited by jim mcnamara; 04-29-2017 at 10:45 PM..
# 2  
Old 04-29-2017
There are lots of systems like Solaris 10 that are going to be way back - at 3.3 bash, for example.

So, what do you want to do? I would try ksh88 which is close to Linux pdksh. Most systems have that as a fall back. You can also download older versions of bash if you want.

KornShell -> to download ksh 88.

Earlier bash: Index of /gnu/bash
I do not know how well early bash versions like 1.14 behave in new environments.
This User Gave Thanks to jim mcnamara For This Post:
# 3  
Old 04-29-2017
Jim mentioned Solaris 10. The version of bash running on the latest release of macOS (macOS Sierra Version 10.12.4) is even older:
Code:
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin16)
Copyright (C) 2007 Free Software Foundation, Inc.

This User Gave Thanks to Don Cragun For This Post:
# 4  
Old 04-30-2017
Thank you. I'll download 3.2.57(1) version and change code accordingly..

I'm facing problems with array and read options from keyboard which runs fine on my machine on version 4.3.42(5) but when others try to run my code on their 3.x.x version it dosent work.

---------- Post updated at 07:56 PM ---------- Previous update was at 07:54 PM ----------

Thank you. I'll download 3.2.57(1) version and change my code accordingly..

Looks like 4.x.x(which i use) has some array and keyboard input options which dosent work on 3.x.x so i'll have to modify my code.

Last edited by Don Cragun; 04-30-2017 at 01:20 AM.. Reason: Remove duplicated text.
# 5  
Old 04-30-2017
The 'read' statement will more than likely be your Achilles Heel...
read -r -n 1 -s -t .025 key
You can't use a floating point time out timer on the pre-version 4.x.x read statement.
If you use -t 0 for your whole number timer then the keystroke does NOT get put into the 'key' variable. It does get sent to 'stdout' but that is useless.
So the minimum value for your game to work is '-t 1' which is 1 second.

I don't think there is a workaround using inkey() { char="" ; stty -icanon min 0 time 1 ; char=$( dd count=1 2> /dev/null ) ; } either.
(Thanks to Corona688 for showing me this method a few years back.)
# 6  
Old 05-04-2017
Ohh ok. 1 second is too slow for the game i have made. I tried several options and 0.25 is optimum for reading the input from keyboard .With 1 second as time out the snake wont turn in time and will get caught. If possible ,please try downloading version 4.3.42(5) and running the code in it if you have free time.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

GNU & BSD Makefile Directives & Conditions Compatibility

Firstly, I would like to apologize if this is not the appropriate sub-forum to post about GNU/BSD makefile scripting. Though my code is in C++, because I am focusing on the makefile I thought it would go better in shell scripting. Please correct me if I am wrong. Secondly, I am not interested in... (0 Replies)
Discussion started by: AntumDeluge
0 Replies

2. Shell Programming and Scripting

Bash and sed compatibility

Hi i am having a stange problem. Basically for my sed script used within bash i can unly use a single Quote with sed '. (if i use " then i get command garbled error with sed ) The problem with this is BASH does not interprit variables within single quote ' so we cannot use any of the BASH... (7 Replies)
Discussion started by: vash
7 Replies

3. Programming

Backward compatibility in python

Actually I have installed python 3.2. It seems there are a lot of synta variance between 2.2 and 3.2. Is it possible to run a script in 2.2 without actually installing 2.2. But I have installed 3.2. and also is it possible to access the 2.2 shell in 3.2 version. I am naive in python . Please... (1 Reply)
Discussion started by: pandeesh
1 Replies

4. Solaris

IPv6 compatibility issue .

Dear All, Need your advise. Can the Sun Fire V240 or Sun Fire V440 support with IPv6? Or it was depend to the OS? Any supporting document i can refer? Thank for help (0 Replies)
Discussion started by: pcw
0 Replies

5. SCO

sco unix backward compatibility on "max open file per process"

Hi How to increase maximum number of open file in "sco xenix binary" running in "sco unix openserver 5.0.7" ? I have changed "NOFILES" kernel parameter to 512, but xenix binray can't open more than 60. tnx (4 Replies)
Discussion started by: javad1_maroofi
4 Replies

6. Linux

version compatibility of montavista CGE-5.1 with JRE-1.4.2

Dear All, Currently I am using montavista CGE-3.1 and JRE-1.4.2, now I like to upgrade CGE version-3.1 to CGE version-5.1. I like to know whether CGE-5.1 will support JRE-1.4.2 ?. Kindly help in this regards. Raj. (1 Reply)
Discussion started by: rajamohan
1 Replies

7. Shell Programming and Scripting

HP UX and AIX compatibility issue

Hi All, The below code works perfectly on AIX machine but doesnt give the desired o/p on HP UX. Can someone please generalise the code so that it becomes platform independent. awk 'NR == FNR { /^*\47name/ && c++ # get the field number if (/^*\47size/) { split($0, t, ":") ... (2 Replies)
Discussion started by: subhrap.das
2 Replies

8. UNIX for Advanced & Expert Users

Substitute single backward-slash with the double backward-slash

Hi, I have a path like this c:\test\sample\programs, i need to change thiis to c:\\test\\sample\\programs. How to perform this? I tried tr command but it didn't help me. Thanks Vijayan (3 Replies)
Discussion started by: mvictorvijayan
3 Replies

9. Shell Programming and Scripting

bash version or string issue

Hi all, I'm not sure but I guess, that is a bash version issue. The script working fine on "GNU bash, version 3.2.25(1)-release Ubuntu". #!/bin/bash while IFS=">" read a id val do if ] then VAL=${id%<*}; ID=${id#*</} echo $VAL echo $ID sed... (5 Replies)
Discussion started by: research3
5 Replies
Login or Register to Ask a Question