Forum Discussion
Altera_Forum
Honored Contributor
21 years agosh doesn't work ?
Hi, All
I want use shell script , but script does'nt work. It seems '[' character reading fail. Does anybody have a those things and know about how to fix it? My problem shell script and results are below. <div class='quotetop'>QUOTE </div> --- Quote Start --- # /bin/sh -xv test# !/bin/sh if [ $# -ne 2 ]; then echo wrong. exit fi +[ 0 -ne 2 ] [: not found[/b] --- Quote End --- And Under Fedora linux results are below. <div class='quotetop'>QUOTE </div> --- Quote Start --- # /bin/sh -xv test# !/bin/sh if [ $# -ne 2 ]; then echo wrong. exit fi + '[' 0 -ne 2 ']'+ echo wrong. wrong. + exit[/b] --- Quote End --- http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/huh.gif4 Replies
- Altera_Forum
Honored Contributor
Try:
if test $# -ne 2; then echo wrong. exit fi It's an alternate way of writing the same script and while I haven't tested it under Nios II Linux, I'm reasonably confident it should work. - Altera_Forum
Honored Contributor
Hi, Ken
Thank you for your reply, But It does'nt work and found another problem. first, results for your advice. <div class='quotetop'>QUOTE </div> --- Quote Start --- # cat test# !/bin/sh if $# -ne 2 ; then echo wrong. exit fi # sh -xv test# !/bin/sh if $# -ne 2 ; then echo wrong. exit fi +0 -ne 2 0: not found# [/b] --- Quote End --- and , Another problem. This seemed that child process couldn't run or fail and appear login. I typeed " a=`echo nios`" <div class='quotetop'>QUOTE </div> --- Quote Start --- # a=`echo nios` /etc/issue www.microtronix.com June 2005 Welcome to Linux on the Nios II Nios2 login:[/b] --- Quote End --- http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/dry.gif - Altera_Forum
Honored Contributor
/bin/sh is mostly linked to another shell (bash/dash, ...)
You need to determine what shell you are running on the Nios II (e.g. hush) and see what you are running on your development machine. Only then can you make a fair comparison since not all shell support (obviously) the same syntax set. - Altera_Forum
Honored Contributor
I have the same problems as aqura. (I'm using uClinux 1.4.) When you select "sh" for a new "Nios II Linux Filesystem" project, the information there says that it is indeed bash, so aqura's script is supposed to work.
I think these features of "sh" might just be broken in this release. If anyone has been able to get them to work, please let me know. Alternatively, if anyone knows of a lightweight shell for Nios II uClinux that has working command substitution (i.e. backquoting), then again please let me know.