Re: Bug in /etc/cron.d/mlocate.cron or am I crazy?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/28/09 03:53, quoth Michael Schwendt:
> On Fri, 27 Nov 2009 23:20:23 -0500, Matthew wrote:
> 
>> On Fri, Nov 27, 2009 at 10:55:17PM -0500, Steven W. Orr wrote:
>>> I can't believe this is a real bug. I'm submit it to bugzilla. It's in F10, 11
>>> and 12. I'd be curious to know just how old this bug is.
>>> Contents of mlocate.cron is:
>>> #!/bin/sh
>>> nodevs=$(< /proc/filesystems awk '$1 == "nodev" { print $2 }')
>> [...]
>>> Unless I'm going cuckoo, I'm guessing that the intent was for line two to be:
>>> nodevs=$(< /proc/filesystems | awk '$1 == "nodev" { print $2 }')
>> Have you tried it? The code in the file isn't an error; it's just very
>> obscure bash syntax. That is, $(< /some/file ) is obscure, and $(<
>> /some/file filter-command ) is *really* obscure. Doesn't seem to be
>> documented in the bash manual -- but it works.
> 
> See first chapter of topic "REDIRECTION" in bash manual.
> 
>> And putting a | in the middle there doesn't.
> 
> That would only work as expected when also replacing "<" with "cat".
> 

I am very interested in this question on multiple levels.

Let's start at the first level:

foo=$(< fn bar)

apparently is functionally equivalent to

foo=$( bar < fn )

which really is quite different from

foo=$(cat fn | bar)

which actually runs at least two child processes.

I do *not* see anything in the bash man page, either in the description for
$(< ) which says that it is functionally equivalent to using cat, but does not
explain anything about pipes being illegal in this context. I also do not see
anything of relevance to this topic in the bash man page on REDIRECTION. At
best, the man page is deficient in that it *should* say that the syntax
defaults to qq=$(0< filename) and that other values besides zero are supported.

For example,
qq=$(3< /etc/passwd 0<&3 cat)
actually works.

The other question which seems so obvious to me is the question of how
mlocate.cron should be fixed.

Yes, I agree that if I see that script hanging on a regular basis then I will
provide trace data to Bugzilla for further analysis. But this begs two questions:

1. Should the scripts be written in sh or should we be allowed to use bash
constructs, in this case, like BASH_REMATCH and =~.

2. Even though the solution is a bit longer, is that justification for doing
it the way it's done instead of doing it correctly?

My first proposal:
*********start*************
#!/bin/bash
get_nodevs()
{
    # Return ret as a global
    while read line             # Read each line from /proc/filesystems
    do
        if [[ "$line" =~ $'^nodev\t(.*)$' ]]    # Do a real regex
        then
            (( ${#BASH_REMATCH[@]} == 2 )) && ret="$ret ${BASH_REMATCH[1]}"
        fi
    done < /proc/filesystems
    ret=${ret:1} # Lop off the leading space.
}
ret=''   # ret is global used to return value from get_nodevs
get_nodevs
nodevs="$ret"
{
    renice +19 -p $$
    ionice -c2 -n7 -p $$
| > /dev/null 2>&1
/usr/bin/updatedb -f "$nodevs"
**********end**************

could be correctly implemented in Bourne shell without using any bashisms by
replacing get_nodevs with this:
get_nodevs()
{
    # Return ret as a global
    old_IFS="$IFS"
    IFS='	'   # There's a TAB in there
    while read line             # Read each line from /proc/filesystems
    do
        set -- $line
        [[ $# -eq 2 && "$1" = nodev ]] && ret="$ret $2"
    done < /proc/filesystems
    IFS="$old_IFS"
}

Either way, the original script is deficient because it does not properly
recognize fields 1 and 2.

Am I being too anal? Is it a doc problem? Is it a bug in mlocate that should
be fixed?

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net

Attachment: signature.asc
Description: OpenPGP digital signature

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux