[arch-projects] rc.d bash_completion

Andrwe archlinux at andrwe.org
Thu Jun 9 12:28:25 EDT 2011


On Thu, 9 Jun 2011 16:55:51 +0200, Seblu wrote:
> On Thu, Jun 9, 2011 at 2:43 PM, Dave Reisner <d at falconindy.com> 
> wrote:
>> Sorry, I fail to see how keeping things as strings makes things
>> _easier_. In my experiences, and as shown here, it leads to complex
>> solutions which are not easy to read. I've still yet to sit down and
>> really grok what the hell is going on in that regex.
>>
>> Set subtraction and intersection can be done using grep or comm. I
>> prefer grep as it doesn't require the inputs to be sorted. For
>> example:
>>
>> We can do intersection... elements from array1 are matched with 
>> elements
>> from array2.
>>
>>  $ grep -xFf <(printf '%s\n' "${array1[@]}") <(print '%s\n' 
>> "${array2[@]}")
>>
>> We can do subtraction... array1 is subtracted from array2.
>>
>>  $ grep -vxFf <(printf '%s\n' "${array1[@]}") <(print '%s\n' 
>> "${array2[@]}")
>>
>> And if all else fails, really, what's the problem with using nested
>> for loops? It's iteration of small datasets using bash builtins. 
>> That's
>> guaranteed to be fast enough for this.

Ok, I understood that point. Didn't know of such a usage of grep + 
printf.

>> I've still got 2 major concerns:
>>
>> 1) You're parsing Bash which you expect to have a specific form, 
>> when in
>> fact, there is no required format. Someone could easily come along 
>> and
>> create a script which your completion cannot handle. For all this 
>> added
>> complexity, you get functionality which is going to be rarely used. 
>> I,
>> of course, don't have the final say in this, but I really prefer the
>> simplicity of our current approach. That said, it does have some 
>> bugs. I
>> encourage you to fix them. Which brings me to point 2...

This is a try to fix the most bugs of the current approach by going an 
other way.
If you really think that you can find a fully working initscript which 
can't be handled by the sed command be my guest.
And it already should exist because writing a working script to break 
something isn't hard.
The only scripts I can think of are pushing $1 into a variable an test 
this one for valid actions:

action="${1}"
case "${action}" in
start)
;;
stop)
;;
esac

(I haven't ever seen this in an initscript) or something like this:

if [ "${1}" == "start" ];then
...
elif [ "${1}" == "stop" ]; then
...
else
...
fi

Who is writing and using such a chain of if/else in an initscript?
All the sed command does is:

- removing all lines until "case"-command which tests $1
- removing all lines except the lines which are the patterns of the 
"case"-command
e.g.:
   start)
   stop)
- removing default choices of the case (*))
- replacing ')' and '|' by space to build a list

Indeed that is a heavy combination of sed-commands but it's working 
properly.

Also the main annoyance for the poeple out there is that the completion 
doesn't work for actions which are script-dependent like ifup or 
force-reload.
The only way to fix it without using a 
may-not-work-in-this-and-that-never-seen-condition-command is to add all 
actions which are and will be in the initscripts.
This is IMO unrelyable and can't be handled by anyone.

But if you insist in using the current approach I'll try and fix 
existing bugs.

>> 2) This is still a code dump, and as such, I don't think anyone will
>> accept this regardless of how good or bad it is. You've created a 
>> diff
>> of your script versus what we currently have in git (and not the
>> official git). We accept properly formed patches (that means commit
>> messages) sent with git-send-email. Alternatively, I know Tom is a 
>> fan
>> of pull requests from remote branches, such as my initscripts or
>> mkinitcpio repos on Github.
>
> Functionnality is useful, but i agree on two points.

I didn't know how you want to get patches.
It's the first time I try to sent a patch to arch-dev-list.
Does all people have write-access to your git?
Or how should I commit a modification so you'll get an email?
I mean if I just clone your git and commit it to my clone you'll never 
get a notification.

Is there maybe a wiki-article describing the way how you want to get 
patches?


Kind regards,
Andrwe



More information about the arch-projects mailing list