Dash doesn't understand "source"

Bug #65046 reported by Norm Walsh
6
Affects Status Importance Assigned to Milestone
dash (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Dash claims to be /bin/bash. It isn't. That's evil. But nevermind...

My .profile includes the following lines:

if [ -f ~/.bashrc ]; then
  source ~/.bashrc
fi

To which dash (which is running because Xsession uses /bin/sh and ...) responds:

"source" not found.

The rest of my session naturally goes pear shaped.

Grrrr....

Revision history for this message
Gérard Bigot (gerard-bigot) wrote : Re: [Bug 65046] Dash doesn't understand "source"

Replace source with a simple '.' without the '

G.

On 10/10/06, Norm Walsh <email address hidden> wrote:
>
> Public bug reported:
>
> Dash claims to be /bin/bash. It isn't. That's evil. But nevermind...
>
> My .profile includes the following lines:
>
> if [ -f ~/.bashrc ]; then
> source ~/.bashrc
> fi
>
> To which dash (which is running because Xsession uses /bin/sh and ...)
> responds:
>
> "source" not found.
>
> The rest of my session naturally goes pear shaped.
>
> Grrrr....
>
> ** Affects: dash (Ubuntu)
> Importance: Undecided
> Status: Unconfirmed
>
> --
> Dash doesn't understand "source"
> https://launchpad.net/bugs/65046
>
> --
> ubuntu-bugs mailing list
> <email address hidden>
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
>

Revision history for this message
Norm Walsh (ndw) wrote :

Thanks for the suggestion. I did try that. I got some sort of syntax error, so I still think there's something broken about dash in this area.

Revision history for this message
Micah Cowan (micahcowan) wrote :

The word "source" is a bash extension: the portable version is the dot (".") command.

Please test with the minimally failing example. For instance, with an empty or trivial .bashrc file, does:

if [ -f ~/.bashrc ]
then
    . ~/.bashrc
fi

fail? If not, the bug would seem to be other than the one you've described. If so, please include the exact error message you received.

Also, in what way does dash "claim to be /bin/bash"? If you're referring to the contents of the $SHELL environment variable, you can't blame dash for that: while it's commonly misinterpreted to mean the currently running shell, it actually is set by login (and some shells) to be the value of the user's login shell, as specified by /etc/passwd. That is, if your login shell is /bin/tcsh, and SHELL is currently unset, and you run bash, bash will set SHELL to /bin/tcsh (and not /bin/bash). Dash may possibly do the same: or it may be that it was already set by a parent process.

Changed in dash:
status: Unconfirmed → Needs Info
Revision history for this message
Norm Walsh (ndw) wrote :

My bad. Using "." did work, the error was caused by something *in* my .bashrc, I simply got confused by the error message. Sorry about that.

As for $SHELL, I stand corrected.

The transition from bash to dash caused a regression (in that my previously working login stopped working), but perhaps the bugs are all mine.

Revision history for this message
Micah Cowan (micahcowan) wrote :

In that case, I'll go ahead and close out this bug. Please do continue to report any problems that you find!

Changed in dash:
status: Needs Info → Rejected
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.