mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* Strange behaviour of 'exit' command
@ 2019-06-12 10:42 Ian Abbott
  2019-06-13  7:18 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ian Abbott @ 2019-06-12 10:42 UTC (permalink / raw)
  To: Barebox List

I noticed some strange behaviour in the 'hush' shell when the 'sh' and 
'exit' commands are used:

---------------------------------
barebox:/ sh
barebox:/ exit
t: No such file or directory
barebox:/ echo $?
127
barebox:/
---------------------------------

Also:

---------------------------------
barebox:/ sh
barebox:/ exit 2

sh - execute a shell script

Usage: sh FILE [ARGUMENT...]

t: No such file or directory
barebox:/
---------------------------------

Can anyone else reproduce this?

-- 
-=( Ian Abbott <abbotti@mev.co.uk> || Web: www.mev.co.uk )=-
-=( MEV Ltd. is a company registered in England & Wales. )=-
-=( Registered number: 02862268.  Registered address:    )=-
-=( 15 West Park Road, Bramhall, STOCKPORT, SK7 3JZ, UK. )=-

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Strange behaviour of 'exit' command
  2019-06-12 10:42 Strange behaviour of 'exit' command Ian Abbott
@ 2019-06-13  7:18 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2019-06-13  7:18 UTC (permalink / raw)
  To: Ian Abbott; +Cc: Barebox List

Hi Ian,

On Wed, Jun 12, 2019 at 11:42:24AM +0100, Ian Abbott wrote:
> I noticed some strange behaviour in the 'hush' shell when the 'sh' and
> 'exit' commands are used:
> 
> ---------------------------------
> barebox:/ sh
> barebox:/ exit
> t: No such file or directory
> barebox:/ echo $?
> 127
> barebox:/
> ---------------------------------

After some digging:

in common/hush.c get_user_input() we have:

	static char the_command[CONFIG_CBSIZE];

This string is used for user input and is unfortunately shared between
different shell instances. The 't' that is executed is the 't' from
'exit'. Try ' exit' instead and you'll see the shell trying to execute
'it' ;)

the_command should be dynamically allocated, but since in_str is
currently statically allocated there is no place in the code to free
the_command again after usage.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-06-13  7:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-12 10:42 Strange behaviour of 'exit' command Ian Abbott
2019-06-13  7:18 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox