#9 Set custom PATH in non-login shells
Merged a year ago by svashisht. Opened a year ago by svashisht.
rpms/ svashisht/bash rhbz1615131  into  master

file modified
+5 -1

@@ -7,7 +7,7 @@ 

  Version: %{baseversion}%{patchleveltag}

  Name: bash

  Summary: The GNU Bourne Again shell

- Release: 3%{?dist}

+ Release: 4%{?dist}

  License: GPLv3+

  Url: https://www.gnu.org/software/bash

  Source0: https://ftp.gnu.org/gnu/bash/bash-%{baseversion}.tar.gz

@@ -317,6 +317,10 @@ 




+ * Mon Sep 10 2018 Siteshwar Vashisht <svashisht@redhat.com> - 4.4.23-4

+ - Set custom PATH in non-login shells

+   Resolves: #1615131


  * Thu Jul 12 2018 Fedora Release Engineering <releng@fedoraproject.org> - 4.4.23-3

  - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild


file modified

@@ -6,7 +6,3 @@ 



  # User specific environment and startup programs


- PATH=$HOME/.local/bin:$HOME/bin:$PATH


- export PATH

file modified

@@ -5,6 +5,10 @@ 

  	. /etc/bashrc



+ # User specific environment

+ PATH="$HOME/.local/bin:$HOME/bin:$PATH"

+ export PATH


  # Uncomment the following line if you don't like systemctl's auto-paging feature:

  # export SYSTEMD_PAGER=


.bash_profile is sourced only in login shells. Since .bash_profile
sources .bashrc, it should be safe to set custom PATH in .bashrc.

Resolves: #1615131

I would not add the outstanding # at the end to avoid unnecessary conflicts while merging existing config files.

I would quote right hand side of the assignment:


I know it was not there before. But people take default configuration files as examples while extending their configuration and we should give them good examples wherever possible.

rebased onto 739b272

a year ago

Pull-Request has been merged by svashisht

a year ago

I usually don't quote the RHS of assignments:


This is because wordsplitting, filename expansion, and brace expansion do not occur in variable assignments.

I do add quotes if needed:

full_path_to_file="/directory name with spaces/$f"
full_path_to_file=/directory\ name\ with\ spaces/$f

Discussion: https://stackoverflow.com/q/3958681

Thus I would not say it is a bad example to not put unnecessary quotes on the RHS of an assignment.

Granted this is a stylistic issue over which reasonable programmers can disagree. No big deal.

@robin217 Good point. The quotes are redundant (but harmless) in this specific case.