Tiny Core Linux
General TC => General TC Talk => Topic started by: SunBurnt on August 18, 2011, 08:53:04 AM
-
I finally got some time to stare at TC`s boot scripts more and noticed this:
Not trying to be picky, but wouldn`t this first part of init:
#!/bin/sh
mount proc
grep -qw multivt /proc/cmdline && mv /etc/inittab-save /etc/inittab
if grep -qw embed /proc/cmdline; then
umount proc
exec /sbin/init
fi
umount proc
Be better written as:
#!/bin/sh
mount proc
grep -qw multivt /proc/cmdline && mv /etc/inittab-save /etc/inittab
umount proc
grep -qw embed /proc/cmdline && exec /sbin/init
-
Hi SunBurnt
I don't deal with scripts much, but both ways look like they'll work. However, readability is also
important. Without reading a single line of code I can look at the first version and know a conditional
statement is there, with the second I actually have to read the line to know that. When dealing with a
large script the first way will make it easier to figure out what's going on.
[EDIT]: Spelling correction
-
No, that wouldn't work:
umount proc
grep -qw embed /proc/cmdline && exec /sbin/init
In your version, proc is already gone by the grep.
-
Rich; The line before it was done that way ( no "if [....." ), it seemed good.
curaga; You`re right of course, didn`t look at the content of the command.