Live data from Hacker News

Why Create a New Unix Shell?

oilshell.org

291–298 of 298 posts

Re: Why Create a New Unix Shell?

#291
post #109
post #68

In your FAQ you decry Perl as having no ability to redirect around other programs. Yet you don't explain how any of the following fail to meet those needs.: * http://perldoc.perl.org/functions/open.html * http://perldoc.perl.org/IPC/Open2.html * http://perldoc.perl.org/IPC/Open3.html * http://search.cpan.org/~odc/IPC-Open2-Simple-0.01/lib/IPC/Op... * http://search.cpan.org/~exodist/Child-0.013/lib/Child.pm * http://s…

Can you show me some code? How do you write this in Perl? f() { echo -- ls / echo -- } f > out.txt f | wc -l

And just to be cute, this uses 2 pipes and is shorter (but I would not write it this way).

    #!/usr/bin/perl -w
    use strict;
    use English;
    use autodie;
    
    sub f { open(my $h,"/bin/ls $_[0]|") ; print "--\n",(),"--\n";}
    
    open(my $o,">/tmp/out.txt") ; select $o ; f("/tmp") ;
    open($o,"| wc -l ")         ; select $o ; f("/tmp") ;

Re: Why Create a New Unix Shell?

#292
post #209

Earlier quoted context omitted.

Both support for `&&` and `||` (instead of `and` and `or`) as well as supporting `FOO=bar command` are under consideration for fish 3.0 to ease the migration path. The former is pretty much going to happen, the latter if we get around to it, DV.

This would be much appreciated. I know there are a few people on my team that cam't use fish due to our npm scripts needing to be compatible with cmd

Why don’t your npm scripts specify /bin/sh as the interpreter?

Re: Why Create a New Unix Shell?

#293
post #95
post #53

Earlier quoted context omitted.

One of the werid cases with fish as default shell is scripts and programs that expect bash when executing “system” commands. For instance a php or Java program running shell commands. Having bash compatibility is a quality of life feature, no need to debug all the werid cases where it breaks for purely syntax reasons.

Right, the system() function in C, which PHP probably uses, and is os.system() in Python, is DEFINED to run /bin/sh. You never know when a program might call it (although I agree it is almost always bad practice to use it -- use fork/exec instead.) So basically you should never make /bin/sh fish, because then you will no longer have a Unix system (according to POSIX).

Not sure I understand what you mean. /bin/sh is the system shell, I don't believe it's possible to make it fish unless you change the symlink itself.

On ubuntu, /bin/sh is always dash and it's not possible to change without changing the symlink:

https://wiki.ubuntu.com/DashAsBinSh

So, if you use chsh to make your shell fish, it would have no effect on os.system or the system function in C.

Re: Why Create a New Unix Shell?

#294
post #262
post #109

Earlier quoted context omitted.

Can you show me some code? How do you write this in Perl? f() { echo -- ls / echo -- } f > out.txt f | wc -l

Assuming we have some sequence of commands whose output we want to capture and eliminating any implicit use of the shell from perl, I’d define a sub along the lines of sub output_of { my(@commands) = @_; my $pid = open my $fh, "-|" // die "$0: fork: $!"; return $fh if $pid; for (@commands) { my $grandchild = open my $gfh, "-|" // die "$0: fork: $!"; if ($grandchild) { print while ; close $gfh or warn "$0: close: $!";…

See this thread for the real problem: https://www.reddit.com/r/oilshell/comments/7tqs0a/why_create...

Sorry I got to this late -- I might do a blog post on it. I think your response, along with the 3 or 4 others i got essentially proves my point: "Perl is not an acceptable shell".

Re: Why Create a New Unix Shell?

#295
post #294
post #262

Earlier quoted context omitted.

Assuming we have some sequence of commands whose output we want to capture and eliminating any implicit use of the shell from perl, I’d define a sub along the lines of sub output_of { my(@commands) = @_; my $pid = open my $fh, "-|" // die "$0: fork: $!"; return $fh if $pid; for (@commands) { my $grandchild = open my $gfh, "-|" // die "$0: fork: $!"; if ($grandchild) { print while ; close $gfh or warn "$0: close: $!";…

See this thread for the real problem: https://www.reddit.com/r/oilshell/comments/7tqs0a/why_create... Sorry I got to this late -- I might do a blog post on it. I think your response, along with the 3 or 4 others i got essentially proves my point: "Perl is not an acceptable shell".

You're not saying why any of the above don't solve your problem. Dismissing a solution because you refuse to understand it doesn't prove anything.

Re: Why Create a New Unix Shell?

#296
post #203

Earlier quoted context omitted.

I've had good luck with this module. Much nicer than using os.system() imo. https://amoffat.github.io/sh/

never use os.system. os.system is a hack. Subprocess is a bit verbose to use, though... A wrapper would be nice.

I wasn't recommending os.system() ever, OP used it in the example. Subprocess is better, as you said. I think the sh module is better than Subprocess as well.

Re: Why Create a New Unix Shell?

#297

Earlier quoted context omitted.

> I'm stuck with python2.4 or 2.6 Not even 2.7?! 2.6 hasn't had a security update since 2013[0], I dread to think how old 2.4 is. [0]: https://www.python.org/download/releases/2.6.9/

Python2.4 is what RHEL/CentOS 5 has to work with... And the extended support for that bloody release lasts till 2021. You can install a newer version, but our CentOS 5 machines are meant for compatibility tests, so modifying their setup is unacceptable.

Have you tried using the scl repos from RedHat/CentOS? I use it at work yo enable different versions of Python at a system level if I am unable to muck with it because of yum.

I believe they are available for CentOS 5.x?

Re: Why Create a New Unix Shell?

#298

Earlier quoted context omitted.

Anything that supports pipes and signals, and is easy to install. I've started using Steel Bank Common Lisp (SBCL) because it's the default implementation used with the Roswell installer. https://github.com/roswell/roswell (As a side-note: Perl 5 was really the ideal language for this, by design; we might be in a different world today if it hadn't been derailed by Perl Forever^W 6).

I mean, Perl 5 wasn't actually ideal for this, but it was better suited to the task than anything else that actually exists.

Perl 6 actually exists and has a REPL which Perl 5 lacked.
Post reply on HN