bb-1.22.0 and grep -w

Karl Godt karlgodt at excite.de
Sat Jan 18 08:25:25 UTC 2014


Dear Busybox-Team !

I am running Puppy Linux as my main OS, that relies on Busybox in the 
intial ramdisk  about  some 70% and also uses Busybox applets after 
switch_root quite a lot .

The Initial-Ramdisk is not used after a traditional "normal" 
installation and /sbin/init in Puppy-4 times had been a link to 
/bin/busybox - but became a script that would run fsck in a pivot_root 
ramdisk if needed and reboot or exec /bin/busybox init if the filesystem 
found ok ( uses a simple flag file ) .

I use code as
LANG=C
todayY=`date +%Y`;[ "$todayY" ] || todayY='9999'
todayM=`date +%m | sed 's/^0//'`;[ "$todayM" ] || todayM=12
todayD=`date +%d | sed 's/^0//'`;[ "$todayD" ] || todayD='1'
#todayYDN=`date +%j`;[ "$todayYDN" ] || todayYDN=100
todayYDN=`date +%j |sed 's%^0*%%'`;[ "$todayYDN" ] || todayYDN=100

echo "
todayY='$todayY'
todayM='$todayM'
todayD='$todayD'
todayYDN='$todayYDN'
"

monthN=`for i in $(seq 1 12) ; do cal $i 1 | head -n 1 | grep -o 
'[[:alpha:]]*' | sed "s/^/$i /"; done`
monthT=`echo "$monthN" | /bin/grep -w "^$todayM"`
montTN=`echo "$monthT" | cut -f 1 -d ' '`
montTO=`echo "$monthT" | cut -f 2 -d ' '`

echo "monthN=$monthN"
echo "monthT='$monthT'"
echo "monthTN='$montTN'"
echo "montTO='$montTO'"

which gave me multiple lines for

todayY='2014'
todayM='1'
todayD='18'
todayYDN='18'

monthN=1 January
2 February
3 March
4 April
5 May
6 June
7 July
8 August
9 September
10 October
11 November
12 December
*monthT='1 January
11 November'
monthTN='1
11'
montTO='January
November'*

Bartosz Golaszewski (6):
      grep: don't bail out on first mismatch if '-w' option is set

seems not to work as it should, it seems to grep '1' , '11' , '111' , 
... if word is '1' , probably because it is a number .


On the other side I am glad that
bash-3.2# ash    


BusyBox v1.22.0Dell755-Opera2 (2014-01-18 04:29:48 GMT+1) built-in shell 
(ash)
Enter 'help' for a list of built-in commands.

/ # grep -w '/' /proc/mounts
rootfs / rootfs rw 0 0
/ #

works , because former it worked as grep -Fw '/' /proc/mounts .


Related to the '/' -character is a minor annoyance while substitution in 
ash :
/ # STRING=/mnt/somewhere/path/to/some/file
/ # echo "${STRING//\/mnt\/somewhere}"
/mnt/somewhere/path/to/some/file
/ # echo "${STRING//\/mnt\/somewhere/}"
/mnt/somewhere/path/to/some/file
/ # echo "${STRING//\/mnt\/somewhere/Replacement}"
/mnt/somewhere/path/to/some/file


With best regards,
Karl Reimer Godt


More information about the busybox mailing list