Shell one-liner: Difference between revisions

→‎{{header|J}}: add some description, and an alternative.
(→‎{{header|J}}: add some description, and an alternative.)
Line 400:
=={{header|J}}==
<syntaxhighlight lang="bash">$ jconsole -js "exit echo 'Hello'"
Hello</syntaxhighlight>
</syntaxhighlight>
 
Here, the (empty) result of <code>echo</code> is used as the exit code argument for <code>exit</code>. And, since it's empty, the the default exit code of 0 is what's actually used. The exit command here is used to prevent the default behavior of jconsole (which is to start the J [[wp:Command_shell|command shell]]) and to instead return to the OS command shell.
That said, note that J interpreters can themselves be thought of as [[wp:Command_shell|command shells]].
 
We could have instead used:
 
<syntaxhighlight lang="bash">$ :|jconsole -js "echo 'Hello'"
Hello
</syntaxhighlight>
 
for nearly identical behavior, but this issues J's command prompt before exiting. (But since J's command prompt is three space characters, this would be nearly invisible in many contexts, including here.)
 
=={{header|Java}}==
6,962

edits