Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[oil-language] Implement overlooked != operator
Caught by Danilo Spinella. - Add test cases from the other examples. - Language FAQ: Explain limited proc / shell function return values. Thanks for the feedback!
- Loading branch information
Andy Chu
committed
Jan 8, 2021
1 parent
d5a31dc
commit 1c3de58
Showing
4 changed files
with
79 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
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
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,55 @@ | ||
# Oil user feedback | ||
|
||
# From Zulip: | ||
# | ||
# https://oilshell.zulipchat.com/#narrow/stream/121540-oil-discuss/topic/Experience.20using.20oil | ||
|
||
#### setvar | ||
|
||
# This seems to work as expected? | ||
|
||
proc get_opt(arg, :out) { | ||
setvar out = $arg | ||
} | ||
var a = '' | ||
get_opt a 'lol' | ||
echo hi | ||
## status: 1 | ||
## STDOUT: | ||
## END | ||
|
||
#### != operator | ||
var a = 'bar' | ||
|
||
# NOTE: a != foo is idiomatic) | ||
if ($a != 'foo') { | ||
echo 'not equal' | ||
} | ||
|
||
if ($a != 'bar') { | ||
echo 'should not get here' | ||
} | ||
|
||
## STDOUT: | ||
not equal | ||
## END | ||
|
||
|
||
#### Regex Literal | ||
|
||
# This seems to work as expected? | ||
|
||
proc get_opt(arg, :out) { | ||
setref out = $(write -- $arg | cut -d'=' -f2) | ||
} | ||
|
||
var variant = '' | ||
var arg = '--variant=foo' | ||
if ( arg ~ / '--variant=' <word> / ) { | ||
get_opt $arg :variant | ||
echo variant=$variant | ||
} | ||
|
||
## STDOUT: | ||
variant=foo | ||
## END |
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