Talk:Shell one-liner

From Rosetta Code

Which Shell?

Which shell? Normally the programming language does not specify existence of any shells or others environmental tasks. What happens if the program is run as an OS driver, a system service, or without any OS at all on the bare board? Otherwise, how does this task differ from Execute a System Command? Does spawning a shell qualify? --Dmitry-kazakov 13:15, 26 August 2008 (UTC)

I guess we could restrict it to mean systems that have command line shells such as bash/tcsh/... on Unix systems, cmd.exe on Windows, or posix-like shells. Maybe we should state what shell the command line is compatible with? --Paddy3118 13:55, 26 August 2008 (UTC)

The examples on the page seem to indicate that the task is running a line of the programming language from a shell; and not doing anything of the shell from the programming language. I am not sure exactly what you are allowed to use; because the OCaml example just echoes a string and pipes it into the ocaml program. You can do that with any language with an interpreter that reads from standard input, so it seems kind of trivial. --Spoon! 19:25, 26 August 2008 (UTC)

As far as I know one-liners are just anything you can fit into a line (or more...!) of a shell, to do a task. So it is ok if you feed an interpreter with input through pipe, at least I believe so. --ShinTakezou 11:02, 9 February 2009 (UTC)

About C and /tmp

Yes but this way it won't work on environments that have not /tmp, or use other convention for directory separator (e.g. \ instead of /); I suppose it would have not worked anyway out of a posix-like shell... --ShinTakezou 11:00, 9 February 2009 (UTC)

It wouldn't have, which is why I felt justified adding /tmp, touch and chmod. /tmp was the only widely-available approach I could think of for temporary files. I would have preferred a means to have gcc output to stdout, and then execute that, but I don't know of any shell or common program that would allow you to execute a raw binary fed in by way of STDIN. --Short Circuit 16:35, 9 February 2009 (UTC)

The C example could be quite shorter:

echo 'main() {printf("Hello\n");}' | gcc -w -x c -; ./a.out ; rm a.out

(But it would overwrite a possible 'a.out' in the current directory...) 187.25.221.53

Remove C and Autohotkey?

... For relying on the underlying shell too much. It seems to me that that phrase was put in the task definition to stop the shell being used to create temporary files, pipe things around, execute multiple commands etc. --Paddy3118 06:31, 5 June 2009 (UTC)

I can't talk about Autohotkey; but for C (and Algol), to me it would possible to switch che code put in this discussion page (I'll do that after testing). --ShinTakezou 13:00, 5 June 2009 (UTC)

BASIC example misinterprets task?

The idea was to invoke the language - in this case BASIC, from a command shell outside of the language, together with one line of text which would become the program for the language to run. The basic example seems to be invoking a command shell and another program from within the BASIC shell. --Paddy3118 06:23, 26 January 2010 (UTC)

I guess I misunderstood the task. There's no standard way to do that for BASIC (many implementations don't have a non-interactive mode, or else can't take their input from stdin). I'll remove it. -- Eriksiers 00:51, 28 January 2010 (UTC)

One Line?

The original aim of the task specified one-line. I wondered why was it was changed to allow multiple line examples?

The current edited task description seems to be at odds with the task title, as "one-liner" has a well known meaning of one line; and not relying on the shell to concatenate several lines into one. --Paddy3118 01:50, 9 March 2010 (UTC)