Skip to content

Commit 41c9c54

Browse files
A Dynamic Collection of Shell Scripts with Educational Purpose
1 parent a6d6a17 commit 41c9c54

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

scripts/bash-ghost-text

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ _ghost_validate_command() {
8181
[[ -z "$first_word" ]] && return 0
8282
[[ "$first_word" == *"="* ]] && return 0
8383

84+
# Skip validation if it's a function declaration (word followed by parentheses)
85+
# Examples: test(), my_func(), func_name()
86+
if [[ "$first_word" =~ ^[a-zA-Z_][a-zA-Z0-9_]*\(\)$ ]]; then
87+
return 0
88+
fi
89+
8490
# Expand tilde (~) to $HOME for path validation
8591
local expanded_word="$first_word"
8692
if [[ "$first_word" == "~"* ]]; then
@@ -133,6 +139,7 @@ _ghost_validate_command() {
133139
# Invalid command
134140
return 1
135141
}
142+
136143
# Notify if the accepted line contains an invalid command
137144
_ghost_validate_and_notify() {
138145
local full_line="$1"

0 commit comments

Comments
 (0)