bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is it normal for `bash -s foo` not to make PS1=foo available from ~/


From: Chet Ramey
Subject: Re: Is it normal for `bash -s foo` not to make PS1=foo available from ~/.bashrc?
Date: Sat, 25 Mar 2017 15:33:47 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

On 3/25/17 12:40 AM, Torka Noda wrote:

> ~/.bashrc:
> ==============================
> #!/bin/bash
> if [ -n "$1" ]; then
>       echo "\$1 set ($1)"
> else
>       echo '$1 not set!'
> fi
> ==============================
> 
> $ bash -s foo
> $1 not set! # <= $1 not available in ~/.bashrc.
> 
> $ echo $1
> foo # <= $1 available afterward from the command-line.
> 
> 
> Is it normal for Bash positional parameters not to be available
> from ~/.bashrc during initialization?

Yes. Bash has always worked like this.  The startup files are read before
the positional parameters are assigned.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]