Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
There Will Be Penalty
May 18, 2002

Makes a great pet!

haha, not sure how case could be implemented without being built in to the shell.

true, false, test, [, etc., sure.

VikingofRock posted:

God I can never remember the difference between [ and [[

[[ is the one you want, [ is legacy

Adbot
ADBOT LOVES YOU

There Will Be Penalty
May 18, 2002

Makes a great pet!
[[ supports regexes and i believe some other additional operators, i'd have to consult bash(1) for more specifics

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug
[quote="“There Will Be Penalty”" post="“476936137”"]
[[ supports regexes and i believe some other additional operators, i’d have to experiment a bunch before giving up and going to snack overflow for more specifics
[/quote]

pseudorandom name
May 6, 2007

There Will Be Penalty posted:

haha, not sure how case could be implemented without being built in to the shell.

true, false, test, [, etc., sure.


[[ is the one you want, [ is legacy

POSIX/SuS documents case/esac as builtins.

spankmeister
Jun 15, 2008






If you're one of those people who still insists to put #!/bin/sh in tyool 2017 but then uses bashisms in the script you should be drawn and quartered i m o

Doom Mathematic
Sep 2, 2008

VikingofRock posted:

God I can never remember the difference between [ and [[

[ is the name of an external executable which was created as a workaround for the fact that the earliest versions of Bash literally had no way to compare variables with one another.

[[ is the actual Bash syntax which was introduced later to meet this need.

Notorious b.s.d.
Jan 25, 2003

by Reene

Suspicious Dish posted:

nah /etc/ doesn't have binaries

/etc used to have binaries

on hp-ux it probably still does :q:

Notorious b.s.d.
Jan 25, 2003

by Reene
shell scripting is really bad

friends don't let friends write new shell scripts

Progressive JPEG
Feb 19, 2003

[quote="“Notorious b.s.d.”" post="“476942746”"]
shell scripting is really bad

friends don’t let friends write new shell scripts
[/quote]

for small stuff it beats dealing with pip

Notorious b.s.d.
Jan 25, 2003

by Reene

Progressive JPEG posted:

for small stuff it beats dealing with pip

python without pypi is still more capable than shell

the base python distribution has everything bash will do for you, and more

Progressive JPEG
Feb 19, 2003

Notorious b.s.d. posted:

python without pypi is still more capable than shell

the base python distribution has everything bash will do for you, and more

python 2 or python 3?

Notorious b.s.d.
Jan 25, 2003

by Reene

Progressive JPEG posted:

python 2 or python 3?

don't care

both better than bash

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug
python is better documented too

Progressive JPEG
Feb 19, 2003

yeah don't get me wrong id rather use python in nearly all cases, but if the task is solved in 5 lines of bash then it's gonna be bash

sb hermit
Dec 13, 2016





Progressive JPEG posted:

yeah don't get me wrong id rather use python in nearly all cases, but if the task is solved in 5 lines of bash then it's gonna be bash

:same:

if you’re just stringing a bunch of utilities and calling a bunch of command lines, it makes no sense to write a python script if you’ve got other stuff to take care of today

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Soricidus
Oct 21, 2010
freedom-hating statist shill

Doom Mathematic posted:

[ is the name of an external executable which was created as a workaround for the fact that the earliest versions of Bash literally had no way to compare variables with one another.

[[ is the actual Bash syntax which was introduced later to meet this need.

nonsense

[ is builtin syntax in bash. there also exists an external executable of that name for historical reasons but using "if [ something ]" in a script does not spawn another process and never has in bash.

[[ is a nonstandard bash extension that exists because they couldn't add all their special snowflake gnu features to [ while remaining mostly posix compliant. it should be avoided if you are writing portable shell scripts, although you'd have to be an idiot to write a portable shell script any time in the last two decades or so

Doom Mathematic
Sep 2, 2008

Soricidus posted:

[ is builtin syntax in bash.

Then why isn't

Bash code:
#!/bin/bash -e

if [ == "" ]; then
  echo "what"
  exit 1
fi

echo "OK"
a syntax error? It runs and prints "OK".

Notorious b.s.d.
Jan 25, 2003

by Reene

Doom Mathematic posted:

Then why isn't

Bash code:
#!/bin/bash -e

if [ == "" ]; then
  echo "what"
  exit 1
fi

echo "OK"
a syntax error? It runs and prints "OK".

i just tested this: the real /usr/bin/[ will raise an error. bash builtin [ is cool with it.

this is roughly example 9 million and 1 of shell scripting being horrible. mothers, don't let your sons grow up to write shell.

Sapozhnik
Jan 2, 2005

Nap Ghost
Speaking of which, whatever happened to Tcl anyway?

It suddenly became deeply unfashionable for some reason.

Cybernetic Vermin
Apr 18, 2005

yeah, seems one of those weird moments of history, it really was a pretty sensible middle-ground between full programming and command processing which anyone could write with minimal training. not to mention that there was a long period where tk was basically about as good as unix gui programming got

i mostly suspect it died out due to not getting the nerd cred of more full-programming-language competitors, despite that not quite being the point

Progressive JPEG
Feb 19, 2003

I blame all those lovely eggdrop scripts that never worked without a rewrite

FlapYoJacks
Feb 12, 2009
The only reason to write a shell script is:

- Doing a series of bash steps over and over quickly. If your bash script has any loops or more logic than: if !, you should be using a better language.

Sapozhnik
Jan 2, 2005

Nap Ghost
if your shell script has a control flow graph then gently caress you

if you are literally just setting up a bunch of env vars and pipelines and command line args then i guess shell is fine

Notorious b.s.d.
Jan 25, 2003

by Reene

Sapozhnik posted:

if your shell script has a control flow graph then gently caress you

if you are literally just setting up a bunch of env vars and pipelines and command line args then i guess shell is fine

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug
initrd images are one of the few places where it is suitable to write a new shell script with relatively complex logic

pseudorandom name
May 6, 2007

The last S3TC patent expires today, so it must truly be the year of Linux on the desktop.

Soricidus
Oct 21, 2010
freedom-hating statist shill
things that I have ever used tcl for:

1. expect scripts
2. fixing a bit in git-gui

in both cases it struck me as non terrible and I could understand why those tools used it

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Soricidus posted:

things that I have ever used tcl for:

1. expect scripts
2. fixing a bit in git-gui

in both cases it struck me as non terrible and I could understand why those tools used it

3. irc bot

BobHoward
Feb 13, 2012

The only thing white people deserve is a bullet to their empty skull
tcl is ok for real short stuff but I'm frequently annoyed by it when writing longer scripts that have to manipulate data. I have to do this because xilinx tools use tcl as an embedded scripting language. there is no bridging to anything else, hope u like tcl friendo

for calibration purposes, annoyed means I often find myself wishing it had the features and documentation quality of perl

FlapYoJacks
Feb 12, 2009

Lysidas posted:

initrd images are one of the few places where it is suitable to write a new shell script with relatively complex logic

nope. There's systemd for that.

Poopernickel
Oct 28, 2005

electricity bad
Fun Shoe

BobHoward posted:

tcl is ok for real short stuff but I'm frequently annoyed by it when writing longer scripts that have to manipulate data. I have to do this because xilinx tools use tcl as an embedded scripting language. there is no bridging to anything else, hope u like tcl friendo

for calibration purposes, annoyed means I often find myself wishing it had the features and documentation quality of perl

I've done an awful lot of Vivado scripting - my takeaway is that TCL is actually a p. dece language, except for the fact that it's completely unlike everything else out there.

also I'm not the biggest fan of "everything is a string" scripting languages

Poopernickel fucked around with this message at 01:32 on Oct 3, 2017

Soricidus
Oct 21, 2010
freedom-hating statist shill

BobHoward posted:

for calibration purposes, annoyed means I often find myself wishing it had the features and documentation quality of perl

perl5 is far less bad than its reputation suggests. it's usually the first thing I reach for when a bash script becomes complicated enough to need replacing with an actual program. I wouldn't use it for much else these days but it's very good for that specific task

There Will Be Penalty
May 18, 2002

Makes a great pet!
perl5 is good

jony neuemonic
Nov 13, 2009

Soricidus posted:

perl5 is far less bad than its reputation suggests. it's usually the first thing I reach for when a bash script becomes complicated enough to need replacing with an actual program. I wouldn't use it for much else these days but it's very good for that specific task

perl5 gets a ton of unwarranted hate. you shouldn't build applications with it (though it's not much worse at it than any other p-lang and everyone seems to be fine with those, whatever) but it's great at glueing things together or monkeying with text and often way nicer than the equivalent chaining stuff together in bash.

perl6 seems pretty bad though.

Ellie Crabcakes
Feb 1, 2008

Stop emailing my boyfriend Gay Crungus

jony neuemonic posted:

perl5 gets a ton of unwarranted hate. you shouldn't build applications with it (though it's not much worse at it than any other p-lang and everyone seems to be fine with those, whatever) but it's great at glueing things together or monkeying with text and often way nicer than the equivalent chaining stuff together in bash.
For anything super-serious, p-langs mostly delegate to native anyway.

quote:

perl6 seems pretty bad though.
Perl6 is the Chinese Democracy of programming languages.

OldAlias
Nov 2, 2013

jony neuemonic posted:

perl5 gets a ton of unwarranted hate. you shouldn't build applications with it (though it's not much worse at it than any other p-lang and everyone seems to be fine with those, whatever) but it's great at glueing things together or monkeying with text and often way nicer than the equivalent chaining stuff together in bash.

perl6 seems pretty bad though.

:same:

OldAlias
Nov 2, 2013

There Will Be Penalty
May 18, 2002

Makes a great pet!
looked at the copyright date and i cannot loving believe perl6 has been around that long

Adbot
ADBOT LOVES YOU

atomicthumbs
Dec 26, 2010


We're in the business of extending man's senses.
ocaml

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply