Skip to content

Commit

Permalink
shells enhanced RegEx for bash and zsh
Browse files Browse the repository at this point in the history
  • Loading branch information
silverqx committed Sep 9, 2024
1 parent 3a58ca1 commit 545420b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions tom/include/tom/commands/stubs/integratestubs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ __tom_connections() {
# Nothing found
[[ ${#lines[@]} -eq 0 ]] && return
regex='.*"(\w+)".*// shell:connection'
regex='"([[:alnum:]_.-]+)".*// shell:connection$'
for line in "${lines[@]}"; do
if [[ $line =~ $regex ]]; then
Expand Down Expand Up @@ -263,8 +263,10 @@ __tom_connections() {
# Nothing found
[[ $#lines -eq 0 ]] && return
regex='"([[:alnum:]_.-]+)".*// shell:connection$'
for line in $lines; do
if [[ $line =~ '.*"(\w+)".*// shell:connection' ]]; then
if [[ $line =~ $regex ]]; then
connections+=$match[1]
fi
done
Expand Down
2 changes: 1 addition & 1 deletion tools/completions/tom.bash
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ __tom_connections() {
# Nothing found
[[ ${#lines[@]} -eq 0 ]] && return

regex='.*"(\w+)".*// shell:connection'
regex='"([[:alnum:]_.-]+)".*// shell:connection$'

for line in "${lines[@]}"; do
if [[ $line =~ $regex ]]; then
Expand Down
4 changes: 3 additions & 1 deletion tools/completions/tom.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ __tom_connections() {
# Nothing found
[[ $#lines -eq 0 ]] && return

regex='"([[:alnum:]_.-]+)".*// shell:connection$'

for line in $lines; do
if [[ $line =~ '.*"(\w+)".*// shell:connection' ]]; then
if [[ $line =~ $regex ]]; then
connections+=$match[1]
fi
done
Expand Down

0 comments on commit 545420b

Please sign in to comment.