Shell Scripting...how i hate thou.

homercles337

Diamond Member
Dec 29, 2004
6,340
3
71
This new position is very heavy on the scripting (mostly bash) and i hate heavy scripting. In the past i used bash lightly, but in this new field folks are fond of writing bash scripts that are thousands of lines (did i mention they put these scripts in the /bin dir and strip the file extension?). I am a scientist who uses programming as a tool and i like IDEs (my tools are C/C++ and matlab and their IDEs). So given this information, what are the best tools to use for bash scripting. Why is there nothing that allows one to set break points and view the current variable space?
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,836
4,815
75
Googling for a Bash debugger turned up some interesting results. But I've never tried such a thing.

If you can't install anything else, "set" will display a full list of current variables. With grep it could be useful.

Most people are smart enough to either make small, modular scripts, or switch to Perl when their scripts get that big, or both. ;)
 

homercles337

Diamond Member
Dec 29, 2004
6,340
3
71
Most people are smart enough to either make small, modular scripts, or switch to Perl when their scripts get that big, or both. ;)

I do use set for various things, but one of the "scripts" (often in the /bin dir with no extension) im currently looking at is 6800 lines and can often take over a day to run. Surely there is a better option for this sort of stuff than simply commenting sections, using set, or echo. Looking at a wall of text is not very productive. Its all very archaic and reminds of learning C on a Sun 3 when i was in grad school over 10 years ago. There is nothing "rapid" about any of this stuff. Sigh...
 

uOpt

Golden Member
Oct 19, 2004
1,628
0
0
So given this information, what are the best tools to use for bash scripting.

A rope :)

Why is there nothing that allows one to set break points and view the current variable space?

If the variables are exported you can do this
Code:
statement
statement
bash # insert an interactive shell here, that allows you to poke around until you say "exit"
statement

In general, it might be better to move things so that state is held less in variables and more in either files or sqlite databases.
 

ForumMaster

Diamond Member
Feb 24, 2005
7,792
1
0
Most people are smart enough to either make small, modular scripts, or switch to Perl when their scripts get that big, or both. ;)

  1. scripts that long should definitely be split into several smaller scripts.
  2. perl? come on ken! python is much better! we've evolved! you can mix bash and python as well.
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,836
4,815
75
perl? come on ken! python is much better! we've evolved! you can mix bash and python as well.
Python's nice, except that I hate the indent thing. I'd rather have my editor indent lines than have to do them manually. I've even tried making a preprocessor that would take C-style blocks and turn them into Python indents; but I never got very far with that.

You can mix `bash` and Perl as well. :)
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Python's nice, except that I hate the indent thing. I'd rather have my editor indent lines than have to do them manually. I've even tried making a preprocessor that would take C-style blocks and turn them into Python indents; but I never got very far with that.

You can mix `bash` and Perl as well. :)

Same here, I'll take perl over python any day.