• Re: "rehash" not working from within a script?

    From Hank Shiffman@hank@disordered.org to comp.sys.mac.system,comp.sys.mac.misc on Wednesday, July 09, 2003 18:07:24
    From Newsgroup: comp.sys.mac.system

    In article <yE2Pa.37772$C83.3073630@newsread1.prod.itd.earthlink.net>,
    <JHawkins@HumanitiesSoftware.Com> wrote:

    Hi,

    I have a simple script to automate turning text files into scripts.
    Operating on a file, it should make it executable, copy it to a script location that is in my $path variable, and then rehash so it is immediately available.

    Everything except the "rehash" is working from the script. However, it I manually rehash after running it, it works. Whats up?

    <BEGIN SCRIPT>
    #!/bin/tcsh
    chmod 755 $1
    mv $1 /TerminalScripts/
    rehash
    <END SCRIPT>

    Thanks!
    --
    Jeffrey A. Hawkins
    Information Systems Supervisor
    Humanities Software, a division of Renaissance Learning, Inc.

    The problem is that the wrong instance of the shell is getting the
    rehash. Your shell is firing up another instance of the shell (another process) to run the script. And it's that second shell that does the
    rehash, not the one that invoked it. Don't know how to fix that, beyond switching to a shell like 'zsh' that doesn't need manual rehashing.

    --
    Hank Shiffman http://www.disordered.org
    Have Opinion, Will Travel hank@disordered.org Mountain View, California
    --- Synchronet 3.18b-Win32 NewsLink 1.113
  • From Jerry Kindall@jerrykindall@nospam.invalid to comp.sys.mac.system,comp.sys.mac.misc on Wednesday, July 09, 2003 20:31:05
    From Newsgroup: comp.sys.mac.system

    In article <hank-B26AD6.18072409072003@news.fu-berlin.de>, Hank
    Shiffman <hank@disordered.org> wrote:

    In article <yE2Pa.37772$C83.3073630@newsread1.prod.itd.earthlink.net>,
    <JHawkins@HumanitiesSoftware.Com> wrote:

    Hi,

    I have a simple script to automate turning text files into scripts. Operating on a file, it should make it executable, copy it to a script location that is in my $path variable, and then rehash so it is immediately available.

    Everything except the "rehash" is working from the script. However, it I manually rehash after running it, it works. Whats up?

    <BEGIN SCRIPT>
    #!/bin/tcsh
    chmod 755 $1
    mv $1 /TerminalScripts/
    rehash
    <END SCRIPT>

    Thanks!
    --
    Jeffrey A. Hawkins
    Information Systems Supervisor
    Humanities Software, a division of Renaissance Learning, Inc.

    The problem is that the wrong instance of the shell is getting the
    rehash. Your shell is firing up another instance of the shell (another process) to run the script. And it's that second shell that does the rehash, not the one that invoked it. Don't know how to fix that, beyond switching to a shell like 'zsh' that doesn't need manual rehashing.

    Make an alias that runs that script, then does a rehash.

    --
    Jerry Kindall, Seattle, WA <http://www.jerrykindall.com/>

    When replying by e-mail, use plain text ONLY to make sure I read it.
    Due to spam and viruses, I filter all mail with HTML or attachments. --- Synchronet 3.18b-Win32 NewsLink 1.113