Show HN: Bish – Shell scripting with a modern feel
21–30 of 44 posts
Re: Show HN: Bish – Shell scripting with a modern feel
#22Re: Show HN: Bish – Shell scripting with a modern feel
#23 $ docker run -ti imiell/sd_bish /bin/bash
bash-4.3# bish
USAGE: bish
Compiles Bish file to bash.
Magic here:https://github.com/ianmiell/shutit-distro/blob/master/bish/b...
Note I needed to hack the code a little.
Re: Show HN: Bish – Shell scripting with a modern feel
#24I don't think this improves on Perl. Being compiled to Bash might be interesting, if your deployment systems don't have Perl. It used to be unthinkable that any UNIX/Linux system wouldn't have Perl...but, several distros no longer install Perl by default (which is annoying as hell, to me, as Python isn't at all an acceptable substitute for one-liners and shell+ tasks). But, in that case, it would need to compile down to POSIX shell, because Ubuntu doesn't install bash by default, it uses ash (a small POSIX shell). So, bash has the exact same flaw as Perl for that use case.
Anyway, I don't generally think this adds things that I wish for when working with shell scripting, and having to compile it (even a quick compilation like this is likely to be) takes away one of the biggest benefits of scripting languages.
Re: Show HN: Bish – Shell scripting with a modern feel
#25Perl started with roughly the same goal. awk, sed, grep, etc. weren't quite powerful enough, C was too low-level, Perl mixed them all up with real programming language features, while still being very usable in one-liners. I don't think this improves on Perl. Being compiled to Bash might be interesting, if your deployment systems don't have Perl. It used to be unthinkable that any UNIX/Linux system wouldn't have Perl…
This seems like a really bad idea, since it apparently throws out good things like pipes, input/output redirection, wildcard expansion, and interactivity, but doesn't offer anything over the standard scripting languages.
Re: Show HN: Bish – Shell scripting with a modern feel
#26def printall(files) { for (f in files) { print(f); } } # cwd, ls, and cd are all builtin functions. dir = cwd(); files = ls(); print("Files in current directory $dir:"); printall(files); cd("/"); files = ls(); print("Files in root directory:"); printall(files); Whats wrong with this, much shorter Bash sequence: echo Files in current directory `pwd`: ls cd / echo Files in root directory: ls
(OP here). You're right: for simple tasks like listing files or changing directories, you probably don't need bish. I should come up with some better examples where bish wins in readability.
Re: Show HN: Bish – Shell scripting with a modern feel
#27Earlier quoted context omitted.
I believe the problem comes when trying to do stuff like check to see if a file is in a directory. I'm a ZSH user myself, and my default scripting language is Python for similar reasons to the OP's for inventing Bish. I can't for the life of me figure out the syntax for an if statement, especially for things like checking if files exist. Yes, Bash or Zsh have a shorter syntax for the example, but to do something like…
I'm with you. I have written a mountain of Bash scripts to solve various one-off problems, and I'm fucked if I can ever remember the nuances from one time to the next -- when to use [], when [[]], when () or (()), when the dollar sign precedes (), etc. Every single time I have to do anything in Bash I have to re-learn Bash. I suppose I keep using it because, even with having to re-learn every single element of Bash c…
Double-parentheses (( )) are only for arithmetic, e.g. "((count++))" or "echo $((1+1))"
The dollar sign precedes parentheses--i.e. $()--when you're substituting the output of a command, e.g. "echo Today is $(date)". It's easy to remember, because it's just like using the dollar sign for substituting the value of a variable, i.e. "date=$(date); echo $date".
You might want to look into the fish shell. Its scripting is much less idiosyncratic. You don't have to quote any variables, arrays, or command substitutions. e.g.:
set foods apple banana 'cucumber casserole'
for f in $foods
echo $f
end
prints: apple
banana
cucumber casserole
...not: apple
banana
cucumber
casserole
...as would be the case if you forgot to quote "$foods" and "$f" in Bash.Re: Show HN: Bish – Shell scripting with a modern feel
#28 from sh import date, ls, egrep, git
print date(), ls('~/project')
print egrep(ls('~/project'), '-o', '\.py$')
print git.add(egrep(ls('~/project'), '-o', '\.py$'))
[1] http://amoffat.github.io/sh/Re: Show HN: Bish – Shell scripting with a modern feel
#29Earlier quoted context omitted.
I believe the problem comes when trying to do stuff like check to see if a file is in a directory. I'm a ZSH user myself, and my default scripting language is Python for similar reasons to the OP's for inventing Bish. I can't for the life of me figure out the syntax for an if statement, especially for things like checking if files exist. Yes, Bash or Zsh have a shorter syntax for the example, but to do something like…
I'm with you. I have written a mountain of Bash scripts to solve various one-off problems, and I'm fucked if I can ever remember the nuances from one time to the next -- when to use [], when [[]], when () or (()), when the dollar sign precedes (), etc. Every single time I have to do anything in Bash I have to re-learn Bash. I suppose I keep using it because, even with having to re-learn every single element of Bash c…
[1] https://github.com/yramagicman/dotfiles [2] https://github.com/yramagicman/zsh-aliases [3] https://github.com/mathiasbynens/dotfiles/blob/master/.funct...