I have file called install.sh
and within this file I write something to $HOME/.bashrc
file and after that I must call source
command.
In terminal I can type source $HOME/.bashrc
but I can't do this in bash script. If I write this to file, then I get following error:
./install.sh: 1: ./install.sh: source: not found
I am using Ubuntu 12.04 x64.
Any suggestions how to do that?
#!
line#!/bin/sh
? or#!/bin/bash
? – Sergiy Kolodyazhnyy Aug 25 '15 at 19:38sh
andbash
support.
as a name forsource
eg. ./install.sh
– ctrl-alt-delor Aug 25 '15 at 19:43.
is POSIX, so thesource
might be the problem here (if it is not run underBASH
but ratherSH
). – FelixJN Aug 25 '15 at 19:45.
is POSIX compliant, whilesource
is not. So in case he tries to source the file via thesource
command but is doing so withSH
, he will fail. Did that clarify it? – FelixJN Aug 25 '15 at 20:19but
should be followed by a comma (,
). The phrase before the comma, should may sense on its own: be a valid sentence. – ctrl-alt-delor Aug 25 '15 at 21:33.bashrc
from a script..bashrc
is meant to be executed only in interactive environments; it's for setting up terminal parameters, prompts, completion, etc. Don't set environment variables in.bashrc
. What are you really trying to achieve? – Gilles 'SO- stop being evil' Aug 25 '15 at 23:44