-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from o11c/zsh
Add a good zsh solution
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/zsh | ||
# This solution uses no external commands and does not open itself as input. | ||
# Shells do not support the concept of returning strings from functions. | ||
|
||
debug_trap() | ||
{ | ||
if [[ "${ZSH_DEBUG_CMD/ }" == 'g('* ]] | ||
then | ||
local cmd | ||
cmd=${ZSH_DEBUG_CMD//'()'/o} | ||
rv=${cmd//[^a-z]/} | ||
echo $rv | ||
set -e | ||
return | ||
fi | ||
} | ||
|
||
al=1 | ||
trap debug_trap DEBUG | ||
|
||
g()()()('al') | ||
g()()('al') | ||
g()('al') | ||
g('al'); | ||
g()('at') | ||
g()()('at') | ||
g()()()('at') |