[OE-core] [PATCH 1/2] base-files: profile: Do not assume that the 'command' command exists

Mike Looijmans mike.looijmans at topic.nl
Mon Sep 18 11:31:26 UTC 2017


On 18-09-17 10:49, Peter Kjellerstedt wrote:
>> 

Kind regards,

Mike Looijmans
System Expert

TOPIC Products
Materiaalweg 4, NL-5681 RJ Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: mike.looijmans at topicproducts.com
Website: www.topicproducts.com

Please consider the environment before printing this e-mail



-----Original Message-----
>> From: openembedded-core-bounces at lists.openembedded.org
>> [mailto:openembedded-core-bounces at lists.openembedded.org] On Behalf Of
>> Mike Looijmans
>> Sent: den 18 september 2017 10:39
>> To: openembedded-core at lists.openembedded.org
>> Cc: Mike Looijmans <mike.looijmans at topic.nl>
>> Subject: [OE-core] [PATCH 1/2] base-files: profile: Do not assume that
>> the 'command' command exists
>>
>> The "command" shell command appears to be a bashism, the standard
>> busybox shell doesn't implement it.
>>
>> This avoids the following error when logging in to a host that does
>> not have the 'command' command:
>>
>>      -sh: command: not found
>>
>> It also simplifies the code and reduces the number of forks.
>>
>> Fixes: e77cdb761169e404556487ac650dc562000da406
>> Signed-off-by: Mike Looijmans <mike.looijmans at topic.nl>
>> ---
>>   meta/recipes-core/base-files/base-files/profile | 14 ++++++--------
>>   1 file changed, 6 insertions(+), 8 deletions(-)
>>
>> diff --git a/meta/recipes-core/base-files/base-files/profile b/meta/recipes-core/base-files/base-files/profile
>> index ceaf15f..b5b533c 100644
>> --- a/meta/recipes-core/base-files/base-files/profile
>> +++ b/meta/recipes-core/base-files/base-files/profile
>> @@ -22,14 +22,12 @@ if [ -d /etc/profile.d ]; then
>>   	unset i
>>   fi
>>
>> -if command -v resize >/dev/null && command -v tty >/dev/null; then
>> -	# Make sure we are on a serial console (i.e. the device used starts with
>> -	# /dev/tty[A-z]), otherwise we confuse e.g. the eclipse launcher which
>> -	# tries do use ssh
>> -	case $(tty) in
>> -		/dev/tty[A-z]*) resize >/dev/null;;
>> -	esac
>> -fi
>> +# Make sure we are on a serial console (i.e. the device used starts with
>> +# /dev/tty[A-z]), otherwise we confuse e.g. the eclipse launcher which
>> +# tries do use ssh
>> +case $(tty 2>/dev/null) in
>> +	/dev/tty[A-z]*) resize >/dev/null;;
>> +esac
>>
>>   export PATH PS1 OPIEDIR QPEDIR QTDIR EDITOR TERM
>>
>> --
>> 1.9.1
> 
> This is basically the same change as I first sent a patch for in April, and
> last pinged this Friday... The only real difference is that this one misses
> passing error output from resize to /dev/null (which it should do to handle
> the case where tty exists, but resize does not).

Yeah, indeed.

Other problem is that "resize" outputs shell script on stdout to be executed, 
so the proper "total" invokation would be:

   /dev/tty[A-z]*) eval `resize 2>/dev/null` ;;

The "eval" part is missing in your version...



More information about the Openembedded-core mailing list