Bart Schaefer wrote on Fri, Mar 06, 2015 at 23:42:25 -0800: > On Mar 7, 4:27am, Daniel Shahaf wrote: > } Subject: [PATCH] sudo strace -e > } > } Is there a smarter way to detect whether -e was passed to sudo? > > Perhaps > > (( $words[(i)-e] < $words[(i)[^-]*] )) > > would do? That is, the -e appears before the first word that doesn't > begin with a hyphen. The way (i) works in subscripts, the above will > always be true if all the words begin with a hyphen. Good idea, but the RHS will evaluate to 1 since the command word doesn't begin with a hyphen. This seems to work (with extended_glob): (( $words[(i)-e] < $words[(i)^(*sudo|-[^-]*)] )) > A slight tweak might fix the problem with -Ae not working: > > (( $words[(i)-(e|Ae)] < $words[(i)[^-]*] )) -Ae was just an example, 'sudoedit' takes a few other flags (equivalent to getopts "AnSC:g:p:u:"). As you can see, some of these flags take arguments, which may be in separate words. And then there's the '--' arguments terminator. I'm not going to try and handle all those cases. (How common is sudoedit -[x] to begin with, anyway?) The right way is for _arguments to extract that information and provide it back to _sudo. (I don't think that's currently possible; the -> syntax is in the {action} field and -e doesn't take an argument, so there's no way to specify an {action} for it.) Cheers, Daniel