Results 1 to 13 of 13

Thread: Linux Shell?

  1. #1

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205

    Linux Shell?

    Anyone ever had a go at writing a Linux/Unix shell? Or know where I can find some good info or tutes?

    -RJ
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    No, but you can try and find the POSIX shell interface guidelines (the ones that bash is supposed to be following )
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    I know the POSIX guidelines I want to follow. More need implementation stuff. Especially about piping commands, and redirecting output/input...
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    popen(), perhaps?

    Or just look at the bash source.


    Probably the hardest part is the actually parsing interface, and this is where the readline library comes in...
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    I have the functions for opening and using a pipe, it's more the design. I'm pretty unfamiliar with Unix/Linux, so I only have a rough idea of how piping works.

    What's in the readline lib?

    I have a few things I have to do. The first is to make some inbuilt commands, like cd, etc. The second is to implement I/O redirect with >, < operators, and the last is piping.

    Gonna be quite a mission for a 2 week job...
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  6. #6

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    P.S - I downloaded the bash source today. It's about...oh... 300 files...
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  7. #7
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Huge, isn't it.

    But that's because most shells are also programming languages


    The readline library does things like the history, command-line editing, stuff like that.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  8. #8

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    Sorry, exactly 820 files....
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  9. #9
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    In addition to my PM, you might want to look at the glob function, it's quite useful.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  10. #10

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    Will do. What's it do?
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  11. #11
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    It performs "globbing", otherwise known as filename expansion. For example, if I glob the following:
    Code:
    mike@relativity ~] > ls *.txt {a,b,c}.dat
    it could possibly expand this to:
    Code:
    ls z.txt ache.txt lada.txt a.dat b.dat c.dat
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  12. #12
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Yes, I was right amidst writing a set of classes to do this when I stumbled upon this function.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  13. #13

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    Ok, will check it out.
    Oh wait, that doesn't work here...
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

Posting Permissions

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



Click Here to Expand Forum to Full Width