Page 3 of 15 FirstFirst 1234513 ... LastLast
Results 21 to 30 of 149

Thread: Why to love/hate shell scripting

  1. #21
    Join Date
    Sep 2006
    Beans
    2,914

    Re: Why to love/hate shell scripting

    Quote Originally Posted by mssever View Post
    Come to think of it, I'm not sure it's so unique. Consider this case: You have to read multiline input from stdin, sort the lines, strip out all non-unique lines, and print the result to stdout. The way I'd approach this in Ruby is quite similar to the way I'd do it in bash:[code]# Bash
    text="$(while read line; do echo "$line"; done)"
    echo "$(echo "$text" | sort | uniq)"
    Code:
    cat | sort -u
    Or am i missing something ?


    And it's not just manpages. Some commands are documented in info pages, which are a poorly-executed attempt at enabling hyperlinks. Then, there are the builtins, which are documented via the help command. Thus, "man [" and "help [" document two distinct programs. Guess which one you get by default in a shell script?
    I had trouble with man pages when i first started. Don't like it at all. After a while of reading them, i got used to it. man pages are the first thing i go if i forgot a syntax. Whether its info or man page or help, one have to just get used to it. Its simple as that.

  2. #22
    Join Date
    Aug 2006
    Location
    60°27'48"N 24°48'18"E
    Beans
    3,458

    Re: Why to love/hate shell scripting

    IMO the defense of "anything is perfectly fine as long as you just take the time to get used to it" is just way too generic and thus flawed ... I guess you get used to being <reference to actions not suitable for family forum> daily, but I would still not recommend getting to the habit...
    LambdaGrok. | #ubuntu-programming on FreeNode

  3. #23
    Join Date
    Sep 2006
    Beans
    2,914

    Re: Why to love/hate shell scripting

    Quote Originally Posted by CptPicard View Post

    (I should have added .."using glue language with awkward syntax" )
    depending on the situation, there's usually no need to use much glue. If you may, please show an awkward syntax that you encounter.

    the shell's claim to fame really is the idea of combining small tools to do the job.
    and these "tools" are just like Ruby/Python/Perl functions and modules.

    But, the text really is "externally semantic"... you're always outputting and parsing some format that you just have to "know" to regex it right. I think the new fancy Microsoft shell had the correct idea IIRC -- data needs to have some type information to it. As it stands we're just using some kind of weak(?) typing via strings. Nasty.
    whether its weak typing or default type is string or whatever, the shell knows what to do when you tell it to. what is really nasty??

    There is so much more man pages to read and learn the particular oddities (often historical in nature) of whatever you're using compared to having apidocs for libraries in some one given language...
    maybe you want to elaborate more on the difference between reading api docs and man pages?

  4. #24
    Join Date
    Jun 2006
    Location
    CT, USA
    Beans
    5,267
    Distro
    Ubuntu 6.10 Edgy

    Re: Why to love/hate shell scripting

    Very interesting association what gives shell that power: piping simple text through different tools

    CptPicard put it well when he described it as "piping unstructured externally-semantic text between various complex tools with totally different usage.
    Simple general programming language does not have that power right? Because for every change you need to tweak code deep inside loops?

    Yes and no. Traditional language, yes. But Python has generators, and I found fascinating presentation how to use them for **exactly** such kind of processing: Generator Tricks for Systems Programmers (see page 18-20 of PDF, slide I-35..I-39)

    So you can build your filter app 'stacking' one process after another, but you have powerful tool (Python) to build the processing steps exactly as you need.

    Of course this is not killer app for someone who spend 10 years to master all those "small sharp tools" with their own idiosyncratic and quirky switch parameters. But for someone just entering the field, learning just one tool beats that.

    Again, I am not saying that shell should be ignored. I am saying that now there are much better tools to solve problems which used to require sysadmin with 10 years of experience.
    Last edited by pmasiar; September 6th, 2008 at 03:30 AM.

  5. #25
    Join Date
    Sep 2006
    Beans
    2,914

    Re: Why to love/hate shell scripting

    Quote Originally Posted by pmasiar View Post
    Again, I am not saying that shell should be ignored. I am saying that now there are much better tools to solve problems which used to require sysadmin with 10 years of experience.
    Can you give an example of such a problem ?

  6. #26
    Join Date
    Sep 2006
    Beans
    2,914

    Re: Why to love/hate shell scripting

    Quote Originally Posted by CptPicard View Post
    IMO the defense of "anything is perfectly fine as long as you just take the time to get used to it" is just way too generic and thus flawed ... I guess you get used to being <reference to actions not suitable for family forum> daily, but I would still not recommend getting to the habit...
    why is it flawed? How much time did you , for example get used to Python's whitespace or other Python warts? It happens everywhere and everything you do. With practice and practice and more practice, one will know what to do.
    i am also curious what that <reference to actions ...> mean.

  7. #27
    Join Date
    Aug 2006
    Location
    60°27'48"N 24°48'18"E
    Beans
    3,458

    Re: Why to love/hate shell scripting

    Quote Originally Posted by ghostdog74 View Post
    Can you give an example of such a problem ?
    You are aware aren't you that most stuff in a typical distro is not written using a combination of shell tools, for good reason?

    Quote Originally Posted by ghostdog74 View Post
    why is it flawed?
    It is, because I just simply won't agree to believing that anything can be overcome by just "getting used to it" or that before getting used to X and Y, it would not be possible that the other would be easier to "get used to" and that this is actually meaningful.

    It seems to me like an argument against all kinds of progress and development of different languages, because obviously if it held, there would be no point.

    How much time did you , for example get used to Python's whitespace or other Python warts?
    I still don't like it, but I can live with it. Otherwise Python is actually remarkably wart-free, and has very "sensible defaults", which is the whole point here.
    LambdaGrok. | #ubuntu-programming on FreeNode

  8. #28
    Join Date
    Sep 2006
    Beans
    2,914

    Re: Why to love/hate shell scripting

    Quote Originally Posted by CptPicard View Post
    You are aware aren't you that most stuff in a typical distro is not written using a combination of shell tools, for good reason?
    most stuff like for example? Please enlighten me because I don't play with distro's much.

    It is, because I just simply won't agree to believing that anything can be overcome by just "getting used to it" or that before getting used to X and Y,
    we have to agree to disagree then.



    I still don't like it, but I can live with it. Otherwise Python is actually remarkably wart-free, and has very "sensible defaults", which is the whole point here.
    there you go. The key words are "can live with it".
    Perl hackers can live with it, C/C++ lovers can live with it. Java developers can live with it. AFter a while, all hate becomes love.

  9. #29
    Join Date
    Aug 2006
    Location
    60°27'48"N 24°48'18"E
    Beans
    3,458

    Re: Why to love/hate shell scripting

    Quote Originally Posted by ghostdog74 View Post
    most stuff like for example? Please enlighten me because I don't play with distro's much.
    What exactly do you use then, all the time? Take a good, long look inside most source code packages.

    we have to agree to disagree then.
    So you're saying that something like developing Python has indeed been pointless because obviously, Guido could have just got used to awk?

    AFter a while, all hate becomes love.
    No, I couldn't live with brain****, INTERCAL, or by that matter, building the analysis toolkit I make my living with in terms of shell scripts. It would be huge pain no matter how much I tried to get used to it. The awk/sed/bash combination of the algorithms would be completely, utterly unreadable.

    Mind you, I do use awk for collating data from the resultant huge text files full of numbers. It makes for a handy "command-line spreadsheet".

    These kinds of "endless-denial-arguments" à la Lster are really a borderline case of whether they're worth grinding over and over again though...
    LambdaGrok. | #ubuntu-programming on FreeNode

  10. #30
    Join Date
    Jun 2006
    Location
    Gwangju, Korea
    Beans
    3,479

    Re: Why to love/hate shell scripting

    Quote Originally Posted by ghostdog74 View Post
    maybe you want to elaborate more on the difference between reading api docs and man pages?
    In Ruby or Python, there's a central source for documentation, which is well-indexed (especially Ruby's docs). (And there are command-line tools for when you don't need the full documentation site and just need some quick answers.) In the shell, you're fine if you already know the name of the command you want to learn about. Otherwise, you have to use tools like apropos and hope that you search on the right term.

Page 3 of 15 FirstFirst 1234513 ... LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •