Live data from Hacker News

Why Create a New Unix Shell?

oilshell.org

261–270 of 298 posts

Re: Why Create a New Unix Shell?

#261
post #101
post #93

Earlier quoted context omitted.

If your script is over 80-120 lines, it's time for modularization. No sane person writes 1000 line scripts, and the fact that the Oil author uses such a scenario as a reason to use their shell is very disconcerting about the quality of code and I wouldn't touch Oil with a ten-foot pole.

If that's the case, then there are a lot of insane people out there. I sympathize with your opinion on how things should be (though I may or may not agree), but at the end of the day we need to look at what the reality of the world is , not on the ideal way we think people should be using the tools we already have.

Just because writing 1000+ line bash scripts is something that happens doesn't mean it is something one should not avoid.

People also implement new SQL injection bugs every day—just because a lot of people do it doesn't mean we should just let it slide.

Re: Why Create a New Unix Shell?

#262
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

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: $!";
        }
        else {
          exec @$_ or die "$0: exec @$_: $!";
        }
      }

      exit 0; # child
    }
Call it as with

    my $fh = output_of [qw( echo -- )],
                       [qw( ls   /  )],
                       [qw( echo -- )];

    while () {
      print "got: $_";
    }

    close $fh or warn "$0: close: $!";
If implicitly using the shell is acceptable, but we want to interpose some processing, that will resemble

    my $output = `echo -- ; ls / ; echo --` // die "$0: command failed";
    chomp $output;

    print "$0: lines = ", `echo '$output' | wc -l`;
This becomes problematic if the output from earlier commands collides with the shell’s quoting rules. This lack of “manipulexity” that we quickly bump into with shell scripts — that are otherwise great on the “whipuptitude” axis — was a common frustration before Perl. The gap between C and the shell is exactly the niche on POSIX systems that Perl occupies and was its initial motivation.

If all you want to do is redirect anyway, run

    system("{ echo -- ; ls / ; echo -- ; } > out.txt") == 0
      or die "$0: command failed";
Use the appropriate tool for the job. Perl was not designed to replace the shell but to build upon it. The shell is great for small programs with linear control flow. It’s hard to beat the shell for do-this-then-this processing. The real world likes to get more complex and nuanced and inconsistent, however.

Maybe I am missing your point entirely. Do you have a more concrete example in mind?

Re: Why Create a New Unix Shell?

#263

Earlier quoted context omitted.

> They must be short ( Well, the question is: what do you use as a replacement? For my scripts I tend to pull in some version of PHP as soon as needed. Perl is something that's universally available in anything based on Debian or Ubuntu, but it's a maintenance nightmare, and PHP doesn't care whether I use spaces, tabs or a mixture, or if there are due to any circumstances mixed line endings in a file whereas Python m…

If I was ever to be religious, I would believe that PHP was the work of the devil. It's just so... uuuugh. It doesn't make sense. Did you know that you can increment a string in PHP? Yup. Of course you can't decrement it, that's crazy talk. Anyway, I usually avoid perl. While definitely a true programming language, I really don't like it. I find that it lacks clarity, and quickly collapses into bash-like hackery. I p…

It sounds like the original build script was poorly written. Bad (or hurried) programmers write bad code no matter the language.

Are you claiming that its size was because Perl forced it to be long winded?

Re: Why Create a New Unix Shell?

#264

Earlier quoted context omitted.

Early Smalltalk and Lisp systems were those langs all the way down. Using emacs with Common Lisp or using Pharo Smalltalk can give you a feel for this, but not exactly the same thing as a Symbolics lisp machine or the Xerox Alto. Alan Kay has a presentation where he shows the entire OS, word processor, networking stuff, IDE, paint programs...etc was an insanely small amount of code and everything was user configurabl…

I don't know if it's just me, but I don't feel like I'm using a computer when using Windows. After using OpenBSD exclusively for weeks (my laptop broke, so I had to repurpose an old netbook with OpenBSD), I felt bored and limited in Windows. I tried Powershell, but -mostly because I don't know much about it- it didn't give the same feeling. The thing that is working for me is to explore VB.net . It is really an inter…

I've stated on here numerous times that Powershell falls short because pipes aren't text based as in Unix, but are really more like method chaining in .NET. Most of the time I have the output of one command, but can't easily reason about passing it to the next command.

Re: Why Create a New Unix Shell?

#265

Earlier quoted context omitted.

you can turn windows into an adult computer by using cygwin (maybe mingw), autohotkey and something like window manager. the illusion is almost real, because sometimes i also run linux in vmware/docker/... and when i am not paying attention i forget easily which os i am on. the unix subsystem for win is quite boring as you can't mix windows applications with linux ones, for example running visual studio build from ba…

You can run windows programs out of bash (I mean the wsl bash), and you can also create wrapper bat files to use Linux tools/programs from Windows.

True, but it's a hack...not something fluid/elegant/seamless or efficient. I'm not a software engineer. I'm just a traditional engineer that wants an OS written for a power user that allows me to do my job more efficiently. Dealing with a multitude of wrappers is worth it if you're writing production software of course, but not if you write a lot of one off scripts for day to day work.

Re: Why Create a New Unix Shell?

#266

Why is it called Oil? That name is so loaded. I think it actually will give it less of a chance.

I explain the name here:

https://www.reddit.com/r/ProgrammingLanguages/comments/7qn14...

Bizarrely (to me), more than one person thought the name was a play on the company "Shell Oil". Is that the connotation you got from it?

That's unfortunate, but I think as people use it more, the name will take on a different connotation. Guido was fighting "Python == snake" for a long time too (it comes from Monty Python). There were a lot of people that said the name Python was stupid and you couldn't convince your boss to use a language with a name like that.

Re: Why Create a New Unix Shell?

#267
post #73

Earlier quoted context omitted.

fish-shell is the first thing I install on any *nix box I work on, including macOS, VPS servers, desktop (Ubuntu), and even Windows Subsystem for Linux. The feature I use the most is automatic history search by typing part of a command and hitting UP to search the history. I also find the scripting language more straight-forward.

In bash, you can type ^R, then text, to search that text in history interactively. Hit ^R again, if you want to see another match of same text. It saves lot of typing.

It sucks though. The shortcuts are kind of annoying (Ctrl-r, Ctrl-s) and there's no visual cues about the list you're going through.

Re: Why Create a New Unix Shell?

#268
post #208

Earlier quoted context omitted.

Interesting seeing so many fish fans. I absolutely love fish. It makes my everyday shell usage so much nicer. But it seems like a totally unknown shell to most people. I never see anybody else use it at any job I've had. I did use fish a bit as a script language, but I decided for anything of any size I much prefer Julia. For typical file system navigation, fish is better, but Julia is actually pretty decent as a she…

I remember a few years ago poking at julia and thinking it would make a really good shell language. The thing that killed it for this use at the time was slow startup; is that better now?

Much better, it's certainly worth giving it another go. It's still much slower than Python, but it's quick enough that I don't notice it all.

  $ time julia -e 'println("Hi")'
  Hi

  real    0m0.241s
  user    0m0.216s
  sys     0m0.196s
  $ time python3 -c 'print("Hi")'
  Hi
  
  real    0m0.046s
  user    0m0.020s
  sys     0m0.000s

Re: Why Create a New Unix Shell?

#269

So many shells, but how come the virtual terminal hasn't got a revamp or popular alternative? I'd like to see more control over keybinding (e.g. on my machine pressing ctrl+del sends the same character as pressing ctrl+backspace). I understand this would be more a kernel change than a userland one. Screen tiling and visual 'tabs' would also be welcome additions. Not everyone needs a graphic environment, and I refuse…

It has, a fair number of times.

* https://unix.stackexchange.com/a/177209/5132

* https://unix.stackexchange.com/a/196102/5132

Re: Why Create a New Unix Shell?

#270
post #171

Earlier quoted context omitted.

What you are describing has been around since the late 1980s, IEEE POSIX: https://en.wikipedia.org/wiki/POSIX

Well, POSIX is pretty similar to what I mean, but it has a lot of low level stuff and I doubt that Microsoft has any ambitions to transform Windows into a POSIX compatible OS. I thought more about a higher level standard like adding Python, Lua or Qt to every installation by default. As some of those things are pretty heavy I doubt that it would be a wise choice to include them in POSIX. Just imagine a world were you…

> I doubt that Microsoft has any ambitions to transform Windows into a POSIX compatible OS.

Windows NT already is, and has been for many years. It has had two POSIX subsystems over the years, and then a Linux subsystem.

Post reply on HN