-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Confusion re: expr deprecation for strings #41
Comments
Is this just to write the value? Use |
I want to write a shell function that returns a string, without printing it (very functional programming style). But it's not easy, as shell functions normally only return exit codes. For FizzBuzz, I gave up, and had the fizz function go ahead and print the value instead of returning it. My Lisp senses are tingling, but whatcha gonna do... |
Writing to stdout is how you return data from functions. The caller decides what happens to it, whether it's captured or merged with the caller's stdout. It's perfectly functional. |
Interesting. I suppose there are ways to redirect the output before/when the function is executed, so that the user doesn't see the string in the real STDOUT? |
Yes. you can capture/expand the data with In lisp/scheme, There's no "real stdout" in bash, just like there's no "real return value" in lisp. There's just your own return value/stdout, and what the caller did with it. |
Pipe |
38 enh list install recipe
Shellcheck says to replace
expr ...
, asexpr
is deprecated. For mathematical expressions, I can use$((...))
instead. But what should I use for string expressions?FizzBuzz example:
mcandre/toys#2 (comment)
The text was updated successfully, but these errors were encountered: