Subject: Sash

From: Chen Shapira <[email-masked]>
Date: Mon, 3 Jul 2000 14:39:33 +0200

I use Sash (Stand Alone SHell) as my default root shell. Its a pretty good
idea since it has many standard tools as builtins, so even if half my system
is gone and I deleted /lib and /bin, I can still try to save the day.

The main drawback is that while it is very useful at hard times, it isn't as
useful as bash when your system is there.

So once sash starts, you usually type bash, 99.99% of the time bash will
start and everything is fine. The other time - you have some serious
maintainance to do.

But you wouldn't want to type Sash every time, its stupid. You want to put
"bash" into your .sashrc, and bash will run automatically, unless something
went wrong and then it would fall back to Sash.

One problem, .sashrc didn't work, infact "man sash" didn't say a thing about
such an option.

OK, time to add a feature. Thanks god for open-source.

So I opened the Sash source. Now, there's no point in just making in run
Bash, right? I should add the .rc file concept in there, its simple, parse
the file line by line as if its on the command line, fall out to commandline
if something goes wrong.

By now it was late at night, so we started implementing a "safe" mode for
running commands and went to sleep.

Next morning we read the code again.

first thing we find is "readfile" function, parses a file line by line.
Great, now we just need to use it to call a .rc file if it exists, at just
the right moment...
reading abit more, we find that sash already does just that. looks for a
file called .aliasrc in $HOME, runs its commands and startes parsing STDIN.
trying to "cat bash > .aliasrc" worked. Perfect.

Few points:

1) Man pages may lie, Sourcecode doesn't. All hail open source.
2) Avoid programming when asleep.
3) Sash is well written. If anyone wants to see how to write a shell - read
the sash source, its small and well orginised, and with comments too! Very
recomended reading.  

--
Chen Shapira

---

From: Omer Musaev <[email-masked]>
Date: Mon, 03 Jul 2000 14:52:59 +0300

> the sash source, its small and well orginised, and with comments too! Very

4) Debian is the best distribution in the world!!!!!
(uhm. well, there is no connection)
Anyway, great hack!! would like to see it myself:)

> --
> Chen Shapira
>
> ------------------------------------------------------------------------
> Life's too short to send boring email. Let SuperSig come to the rescue.
> http://click.egroups.com/1/6137/12/_/_/_/962624630/
> ------------------------------------------------------------------------
>
> To unsubscribe from this group, send an email to:
> [email-masked]

--
Omer Mussaev    051-308-214   mailto:[email-masked]
systems programmer, Mercury Interactive/RND/Conduct/core

---

From: Gaal Yahas <[email-masked]>
Date: Mon, 3 Jul 2000 22:05:14 +0300

> went wrong and then it would fall back to Sash.

But can you trust it completely to identify WHEN something's wicked
with bash? I tend not to like these solutions. Instead, I do

     echo "exec bash" > ~/b
     chmod +x $!

and then "./b" whenever I log in and all's well. It's part of typing
the root password for my fingers by now.

[I'm lying, of course. I use tcsh as my favorite interactive shell :^]

-- 
believing is seeing
[email-masked]
http://www.forum2.org/gaal/

---

From: Oleg Goldshmidt <[email-masked]>
Date: 03 Jul 2000 23:25:58 +0300

>      chmod +x $!

Why can't you just exec bash? As a matter of fact, I do just that
on a few systems I use where it is useless to ask the admins to
install bash. So I compiled and installed bash in my user space,
and exec it from the default startup file. 

-- 
Oleg Goldshmidt <[email-masked]> 
"... We work but wit, and not by witchcraft;
 And wit depends on dilatory time." [Shakespeare]

---

From: Gaal Yahas <[email-masked]>
Date: Mon, 3 Jul 2000 23:31:20 +0300

> and exec it from the default startup file. 

Because the whole point of using a failsafe shell is that it can't
fail! exec'ing bash automatically carries the (small) risk of throwing
you into a garbaged shell every time you boot during a particular bad
trashing of the system. Remember we're talking about root, not your
favorite user shell.

---

From: Oleg Goldshmidt <[email-masked]>
Date: 03 Jul 2000 23:44:50 +0300

Gaal Yahas <[email-masked]> writes:

> you into a garbaged shell 

I meant, why couldn't you just type "exec bash" rather than a filename
(don't tell me exec bash is too long to type - I'll tell you that it
is much easier to remember :)? I thought Chen said there was no
.sashrc, so we have no place to put exec bash, right? Maybe I
misunderstand the situation - I don't use sash.

The rest of my posting was just an aside comment. I realized too late
it was not precisely on topic.

---

From: Omer Mussaev <[email-masked]>
Date: Tue, 04 Jul 2000 11:46:15 +0300

> it was not precisely on topic.

Few notes:

First: sash has initialisation file, and it is called ${HOME}/.aliasrc

Second: having bash in your ./aliasrc will fork, and then exec bash.
in case there is no bash, sash will continue. in case there is bash,
but no readline, for example, you will get less than functional
bash. in that case, you will be able to exit bash, and fall back
into sash.

One of sash's features is its builtins: it includes gzip, dd, ls, cp, mv
etc.

the only trick is that you"d better put sash in root partition, and not
/usr/bin (I am not sure, but I think that sash installs itself into
/usr on Debian). That way, if you can not get your usr mounted, you will
not lose your socks.

OT: had someone had experience with devfs? I had some nice weekend trying
to get along without devfsd, and wound up patching Xfree in binary (yes, I
am an idiot:)

---

From: Gaal Yahas <[email-masked]>
Date: Tue, 4 Jul 2000 10:00:03 +0300

> misunderstand the situation - I don't use sash.

Well, there may be an ontological question here. Laziness: a moral
*virtue* or an inescapable, metaphysical *necessity*? :-)