![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| bash and ksh: variable lost in loop in bash? | estienne | Shell Programming and Scripting | 2 | 08-25-2008 02:09 PM |
| What can make Cronjobs stop working?? | Nintendo | UNIX for Dummies Questions & Answers | 0 | 06-04-2008 02:40 PM |
| Increment date in 'for' loop? | SunnyK | Shell Programming and Scripting | 4 | 10-30-2007 06:12 AM |
| korn shell to bash - statement not working | brdholman | UNIX for Dummies Questions & Answers | 5 | 10-15-2007 09:49 AM |
| how to stop execution in for loop | useless79 | High Level Programming | 1 | 09-06-2007 10:54 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Anyone know?: How the 'for'-loop could stop working in interactive bash shell?!
It is happening with my sessions already second time: a 'for'-loop for some reason stop to work as expected.
That means or it is looping without exitting, or it is not loop even once. Here example of my try when it is not processing even one loop. You can see, I start new subshell and 'for' works fine, but returning back, the 'for' doesn't work again" Code:
> for ((i=1;i<3;i++));do echo $i; done; > echo mm mm > for ((i=1;i<3;i++));do echo $i; done; > bash executing file .bashrc - starting the bash shell-- ----> Start of the .myset file <--- ---- It is SUN0 box with TEST and MODEL offices ---- ----> End of the .myset file <--- > > > for ((i=1;i<3;i++));do echo $i; done; 1 2 > > exit exit > for ((i=1;i<3;i++));do echo $i; done; > echo boooo boooo > > I do not think it is related to connection soft (I use PuTTY.) Appreciate any help or hint |
|
||||
|
It is correct, you can't reproduce it!
And I too, can not reproduce it! I have this situation second time. First time I have spend couple hours trying to realize what is wrong with my script, untill did not gess to try it in another session, where everything works fine. Now some how it is happened again. Hopefully some time I could learn from past; so I have realized it shortly. Now the session is oppened and I could make some test, if anybody would advice to try anything As I have said, I have no idea how and why that is happening and that is my question, if anybody have any clue about that?!?! |
|
||||
|
Hello,
this may be a long shot, but maybe You have an alias or something that is active in Your first shell (a login shell perhaps, that read .bash_login?) and the next shell is not a login shell and hence has some other definitions that overrule the first ones? save output from alias and set from each shell and compare them. It maybe a lot of text but You said You wanted to understand... ![]() use sort and -u on each file to narrow down size and then diff. /Lakris |
|
||||
|
Thanks Lakris.
Relation to login is not a reason, because a new connection has no problem originally. When that happened I di not know. I have compared the aliases: Code:
> alias >bad_alias > !for for ((i=1;i<3;i++));do ec $i; done; > > Code:
> for ((i=1;i<3;i++));do ec $i; done; 1 2 > alias>good_alias > > > diff bad_alias good_alias > # so files are the same > Later will review (some function I could add, change during mork.) But on first glance there is no real difference. |
|
|||||
|
Hi.
It might be useful to see how the shell is interpreting everything. Using set -x will show you the commands. This is from a vanilla bash called as sh: Code:
$ set -x + set -x sh-2.05b$ for ((i=1;i<3;i++));do echo $i; done; + (( i=1 )) + (( i<3 )) + echo 1 1 + (( i++ )) + (( i<3 )) + echo 2 2 + (( i++ )) + (( i<3 )) |
|
||||
|
Thank you, drl, set -x realy interesting thing.
It seems the shell some how do not processing assighment in the (( )). Also in 'let' and in 'expr' ('ec' is an alianse for echo) Code:
>ec $i; expr i++; ec $i + /usr/bin/echo 2 2 + expr i++ i++ + /usr/bin/echo 2 2 >ec $i; expr i++; expr i=1; ec $i + /usr/bin/echo 2 2 + expr i++ i++ + expr i=1 i=1 + /usr/bin/echo 2 2 >ec $i; expr i++; let i=1; ec $i + /usr/bin/echo 2 2 + expr i++ i++ + let i=1 + /usr/bin/echo 2 2 >ec $i; expr i++; i=1; ec $i + /usr/bin/echo 2 2 + expr i++ i++ + i=1 + /usr/bin/echo 1 1 >ec $i; expr i++; i=$((i++)); ec $i + /usr/bin/echo 1 1 + expr i++ i++ + i=1 + /usr/bin/echo 1 1 > |
![]() |
| Bookmarks |
| Tags |
| linux commands, unix commands |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|