From 8ae9b716a06626798a30497794386ff5cc9e1bef Mon Sep 17 00:00:00 2001 From: Wilke Schwiedop Date: Mon, 26 Mar 2018 19:49:02 +0200 Subject: [PATCH] fix 'grep ... | sed' --- share/completions/lpadmin.fish | 3 +-- share/completions/mvn.fish | 15 ++++++--------- .../__fish_complete_convert_options.fish | 6 ++---- share/functions/__fish_print_xwindows.fish | 3 +-- 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/share/completions/lpadmin.fish b/share/completions/lpadmin.fish index 099309b9b..578b158f9 100644 --- a/share/completions/lpadmin.fish +++ b/share/completions/lpadmin.fish @@ -23,10 +23,9 @@ complete -c lpadmin -s o -d 'Sets the binary communications program to use when complete -c lpadmin -s o -d 'Sets the error policy to be used when the printer backend is unable to send the job to the printer. ' -xa 'printer-error-policy=abort-job printer-error-policy=retry-job printer-error-policy=retry-current-job printer-error-policy=stop-printer' complete -c lpadmin -s o -xa printer-is-shared=true -d 'Sets the destination to shared/published or unshared/unpublished' complete -c lpadmin -s o -xa printer-is-shared=false -d 'Sets the destination to shared/published or unshared/unpublished' -complete -c lpadmin -s o -d 'Sets the IPP operation policy associated with the destination' -xa "printer-policy=(cat /etc/cups/cupsd.conf | grep \/\1/')" +complete -c lpadmin -s o -d 'Sets the IPP operation policy associated with the destination' -xa "printer-policy=(string replace -r --filter '' '$1' < /etc/cups/cupsd.conf)" complete -c lpadmin -s u -xa 'allow:all allow:none (__fish_complete_list , __fish_complete_users allow:)' -d 'Sets user-level access control on a destination. Names starting with "@" are interpreted as UNIX group' complete -c lpadmin -s u -xa '(__fish_complete_list , __fish_complete_groups allow: @)' -d 'Sets user-level access control on a destination. Names starting with "@" are interpreted as UNIX group' complete -c lpadmin -s u -xa 'deny:all deny:none (__fish_complete_list , __fish_complete_users deny:)' -d 'Sets user-level access control on a destination. Names starting with "@" are interpreted as UNIX group' complete -c lpadmin -s u -xa '(__fish_complete_list , __fish_complete_groups deny: @)' -d 'Sets user-level access control on a destination. Names starting with "@" are interpreted as UNIX group' - diff --git a/share/completions/mvn.fish b/share/completions/mvn.fish index 1e99a40bc..a3d50ffb1 100644 --- a/share/completions/mvn.fish +++ b/share/completions/mvn.fish @@ -63,21 +63,18 @@ complete -c mvn -f -o V -l show-version -d "Display version complete -c mvn -f -o v -l version -d "Display version information" complete -c mvn -f -o X -l debug -d "Produce execution debug output" -# # # Profiles # -# -function __fish_mvn_profiles_from_settings - grep -e "" -A 1 ~/.m2/settings.xml | grep -e ".*" | sed 's/.*//' | sed 's/<\/id>.*//g' -end - #TODO search pom.xml hierarchy -function __fish_mvn_profiles_from_pom - [ -e pom.xml ]; and grep -e "" -A 1 pom.xml | grep -e ".*" | sed 's/.*//' | sed 's/<\/id>.*//g' +function __fish_mvn_profiles + # find line opening the profile-tag + # read next line + # extract contents of id-tag + sed -n -e '//{n; s!^.*\([^<]*\).*$!\1!; p}' ~/.m2/settings.xml pom.xml ^/dev/null end -complete -c mvn -f -r -o P -l activate-profiles -a "(__fish_mvn_profiles_from_pom) (__fish_mvn_profiles_from_settings)" -d "Comma-delimited list of profiles to activate" +complete -c mvn -f -r -o P -l activate-profiles -a "(__fish_mvn_profiles)" -d "Comma-delimited list of profiles to activate" #default properties for some plugins / profiles diff --git a/share/functions/__fish_complete_convert_options.fish b/share/functions/__fish_complete_convert_options.fish index 863c83c7f..b32a55120 100644 --- a/share/functions/__fish_complete_convert_options.fish +++ b/share/functions/__fish_complete_convert_options.fish @@ -5,12 +5,10 @@ function __fish_complete_convert_options --description 'Complete Convert options case color Color convert -list color | awk '{ print $1"\t"$2" "$3} ' | sed '1,/----/d' case family - convert -list Font | grep family | sed 's/^\s*.\+: //' | sort -u + convert -list Font | sed '/family/!d; s/^\s*.\+: //' | sort -u case font Font - convert -list Font | grep Font | sed 's/^\s*.\+: //' | sort -u + convert -list Font | sed '/Font/!d; s/^\s*.\+: //' | sort -u case '*' convert -list $what end - - end diff --git a/share/functions/__fish_print_xwindows.fish b/share/functions/__fish_print_xwindows.fish index 58fbecc25..7eef1a6b1 100644 --- a/share/functions/__fish_print_xwindows.fish +++ b/share/functions/__fish_print_xwindows.fish @@ -1,4 +1,3 @@ function __fish_print_xwindows --description 'Print X windows' - xwininfo -root -children | grep '^\s\+0x' | sed '/(has no name)/d; s/^\s*\(\S\+\)\s\+"\(.\+\)":\s\+(\(.*\)).*$/\1\t\2 (\3)/' - + xwininfo -root -children | sed '/^\s\+0x/!d; /(has no name)/d; s/^\s*\(\S\+\)\s\+"\(.\+\)":\s\+(\(.*\)).*$/\1\t\2 (\3)/' end