Skip to contentSkip to conversation

Shell loop bug?

DISCUSSION Alexander Shiyan 2 participants 2 messages Nov 17, 2015

lore
Share & tools
lore
#0 lore raw

Hello.

barebox@/ # for i in /dev/* ; do echo $i; done
/dev/flash0
/dev/full
/dev/m25p0
/dev/m25p1
/dev/mem
/dev/null
/dev/ram0
/dev/self0
/dev/serial1
/dev/zero

barebox@/ # for i in /dev/*1 ; do echo $i; done
/dev/m25p1
/dev/serial1

barebox@/ # for i in /dev/*2 ; do echo $i; done
/dev/*2

     ^^^^^^^^ Is this correct?

Thanks.
---
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#1 lore raw
Quoted 14 lines · Alexander Shiyan

Hello.

barebox@/ # for i in /dev/* ; do echo $i; done
/dev/flash0
/dev/full
/dev/m25p0
/dev/m25p1
/dev/mem
/dev/null
/dev/ram0
/dev/self0
/dev/serial1
/dev/zero

Quoted 7 lines

barebox@/ # for i in /dev/*1 ; do echo $i; done
/dev/m25p1
/dev/serial1

barebox@/ # for i in /dev/*2 ; do echo $i; done
/dev/*2

     ^^^^^^^^ Is this correct?

When there is no /dev/*2, then yes, this is correct.

Try the same under bash, it behaves the same. If there's nothing matching the wildcard pattern then the wildcards are just passed through.

Sascha

Signature · 9 lines
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox