Re: Changing directories, script, mc



On 2008-01-17 Thu 11:08:32, john wrote:

I don't understand what you mean by "source it". Please explain. I found

Others have covered this,

the files mc.sh and mc-wrapper.sh. (I made them both executable). If I
say:

alias mc='. /usr/share/mc/bin/mc-wrapper.sh' [enter]

then mc works as I think it should, so I put that line in my .bashrc. :-)


It doesn't have to be executable, though it'll work that way, too.
Scripts only need to be executable in order to be executed directly. If
you're having the shell source it or giving it as an argument to the
shell, it doesn't need to be executable.

That line looks like what you are talking about re: "source it", but I
don't really understand the concept. If I say:

$. chap1 [enter] konsole exits immediately.

also if I first say:

$alias chap1='. chap1' [enter] then
$chap1 [enter] konsole exits immediately

If I say
$. chap1 [enter] in a console, it results in immediate logout.


I don't use konsole and I'm not sure what would be causing the
exit/logout - especially in a console. If the exit/logout command
appeared in the script, that would be what was doing it - you wouldn't
notice when run as a script, because the subshell would exit anyway, but
you would notice in the current context, because your current shell
would exit. But that's not in the script you gave. Or if you were
running konsole with '-e chap1' and no '-hold' (or equivalent) then it
would immediately exit. Which doesn't seem to be the case and still
wouldn't explain the console.

It works here, though.

I'm "all ears" about this making more sense as an alias or function, too.

As far as the alias, I meant make it an alias directly:

[ j@surfer ][ 01-17 13:34 ][ ~ ]
:alias chap1='cd /sys && ls'

[ j@surfer ][ 01-17 13:34 ][ ~ ]
:chap1
block bus class devices firmware fs kernel module power

Here, you're making it a sort of internal shell command that is issued
as a bare token (no 'sh foo' or '. foo'), is executed in the current
context, doesn't require a separate file (can be issued at the command
line for that instance of the shell or put in your ~/.bashrc for most
every instance of the shell), and shouldn't cause your shell to exit.
Search for /ALIAS in the bash manual (as well as reading up on functions
if you need replaceable parameters) and it talks about all this.
.



Relevant Pages

  • PATCH [1/3]: Replace kernel/timeconst.pl with kernel/timeconst.sh (v2)
    ... The new shell script ... It requires a shell which can do 64 bit math, such as bash, busybox ash, ... makefile so script is responsible for creating output file, ... +trap "rm $FILENAME" EXIT ...
    (Linux-Kernel)
  • Re: Errors when reading a file in Bourne shell -- HELP
    ... I am trying to exit out of the ... the do while and not the shell itself. ... whole shell script. ... to 1 and checking it after the loop. ...
    (comp.unix.questions)
  • Re: exit menu
    ... will exit all the all way or log completely out from the system? ... You can make the menu script into a shell function and call the function from ... Unix Guy Consulting, LLC ...
    (comp.unix.shell)
  • Re: Expect - Solaris 2.8
    ... software program running in the Solaris 2.8 environment. ... but fails to exit back to the shell after completing ... How do I get the script to exit back out ...
    (comp.lang.tcl)
  • Re: Changing directories, script, mc
    ... you're making it a sort of internal shell command that is issued ... deleted the ~bin/chap1 script. ... it works as intended - it can even find the chap1 script in the ~/bin ...
    (comp.os.linux)