File tree Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -11,24 +11,24 @@ skim-stdin() {
1111 #
1212 # Implementation of `pipe-skimming` pattern.
1313 #
14- # Typical usage within Bash-my-AWS:
15- #
16- # - local asg_names=$(skim-stdin "$@") # Append to arg list
17- # - local asg_names=$(skim-stdin) # Only draw from STDIN
18- #
1914 # $ stacks | skim-stdin foo bar
2015 # foo bar huginn mastodon grafana
2116 #
2217 # $ stacks
2318 # huginn CREATE_COMPLETE 2020-01-11T06:18:46.905Z NEVER_UPDATED NOT_NESTED
2419 # mastodon CREATE_COMPLETE 2020-01-11T06:19:31.958Z NEVER_UPDATED NOT_NESTED
2520 # grafana CREATE_COMPLETE 2020-01-11T06:19:47.001Z NEVER_UPDATED NOT_NESTED
21+ #
22+ # Typical usage within Bash-my-AWS functions:
23+ #
24+ # local asg_names=$(skim-stdin "$@") # Append to arg list
25+ # local asg_names=$(skim-stdin) # Only draw from STDIN
26+
27+ local skimmed_stdin=" $( [[ -t 0 ]] || awk ' ORS=" " { print $1 }' ) "
28+
29+ printf -- ' %s %s' " $* " " $skimmed_stdin " |
30+ awk ' {$1=$1;print}' # trim leading/trailing spaces
2631
27- (
28- printf -- " $* " # Print all args
29- printf " " # Print a space
30- [[ -t 0 ]] || awk ' ORS=" " { print $1 }' # Print first token of each line of STDIN
31- ) | awk ' {$1=$1;print}' # Trim leading/trailing spaces
3232}
3333
3434
You can’t perform that action at this time.
0 commit comments