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 [email protected] http://cnswww.cns.cwru.edu/~chet/