FS#12063 - [initscripts] At the end of /etc/rc.sysinit there is a useless check

Attached to Project: Arch Linux
Opened by Francesco Frassinelli (frafra) - Sunday, 09 November 2008, 17:11 GMT
Last edited by Thomas Bächler (brain0) - Sunday, 07 June 2009, 14:07 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Aaron Griffin (phrakture)
Architecture All
Severity Low
Priority Normal
Reported Version None
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

In /etc/rc.sysinit there is a useless check:
419 # Save our dmesg output from this boot
420 if [ -f /var/log/dmesg.log ]; then
421 /bin/rm /var/log/dmesg.log
422 fi
423 /bin/dmesg > /var/log/dmesg.log

The lines between 419 and 422 are useless, because in 423 is used the operator ">", that redirects the output *overwriting* the current file. This check will be ok only if the operator was ">>", that appends the output at the end of file.
This task depends upon

Closed by  Thomas Bächler (brain0)
Sunday, 07 June 2009, 14:07 GMT
Reason for closing:  Fixed
Additional comments about closing:  commited Hugo's fix to git
Comment by Aaron Griffin (phrakture) - Thursday, 04 December 2008, 01:46 GMT
Is it possible that 'noclobber' could be set at this point? That would make the check important
Comment by Gerardo Exequiel Pozzi (djgera) - Sunday, 22 March 2009, 19:07 GMT
Nop, isn't needed but use >|, see...

[djgera@gerardo ~]$ touch hola
-bash: hola: cannot overwrite existing file
[djgera@gerardo ~]$ ls >| hola
[djgera@gerardo ~]$

From bash(1):
If the redirection operator is >, and the noclobber option to the set builtin has been enabled, the redirection will fail if the file whose name
results from the expansion of word exists and is a regular file. If the redirection operator is >|, or the redirection operator is > and the
noclobber option to the set builtin command is not enabled, the redirection is attempted even if the file named by word exists.
Comment by Gerardo Exequiel Pozzi (djgera) - Sunday, 22 March 2009, 19:09 GMT
sorry, i edited bad

$ set -o noclobber
$ touch hola
$ ls > hola
-bash: hola: cannot overwrite existing file
$ ls >| hola
$
Comment by Gerardo Exequiel Pozzi (djgera) - Monday, 27 April 2009, 23:40 GMT
  • Field changed: Percent Complete (100% → 0%)
Can use the operator ">|" that overrides noclobber. See my comment.
Comment by Hugo Doria (hdoria) - Wednesday, 27 May 2009, 19:33 GMT
Here goes a small patch that fixes that problem.

Loading...