Skip to contentSkip to conversation

bash: add default bash settings

PATCH New David Van Arnem 3 participants 3 messages Oct 12, 2015 – Dec 20, 2015

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 bash: add default bash settings

Settings that were bash-specific were previously removed from system/skeleton/etc/profile. This measn that users using bash no longer get the "normal" bash prompt with [user at host dir]#/$, and only get #/$. This commit adds back the bash-specific settings, but adds them to the bash package so they are only used when bash is installed on the target system.

bash_profile.sh contains the variables, aliases, and color profile that were previously in system/skeleton/etc/profile. The changes to bash.mk use a post-install hook to install bash_profile.sh to the target filesystem, where it will later be sourced by /etc/profile when a bash shell is started.
---
Changes v1 -> v2
- only export PS1 variable for bash_profile.sh

---
 package/bash/bash.mk         | 7 +++++++
 package/bash/bash_profile.sh | 5 +++++
 2 files changed, 12 insertions(+)
 create mode 100644 package/bash/bash_profile.sh
package/bash/bash.mk +7 -0
index 97d7182..dae3bf2 100644
@@ -49,4 +49,11 @@ define BASH_INSTALL_TARGET_CMDS
 	rm -f $(TARGET_DIR)/bin/bashbug
 endef
 
+# install default bash settings
+define BASH_INSTALL_DEFAULT_PROFILE
+	$(INSTALL) -D -m 644 package/bash/bash_profile.sh \
+		$(TARGET_DIR)/etc/profile.d/bash_profile.sh
+endef
+
+BASH_POST_INSTALL_TARGET_HOOKS += BASH_INSTALL_DEFAULT_PROFILE
 $(eval $(autotools-package))
package/bash/bash_profile.sh new file +5 -0
new file mode 100644
index 0000000..3fb087a
@@ -0,0 +1,5 @@
+# default bash script, should be sourced by /etc/profile
+
+if [ "$PS1" ]; then
+    export PS1="[\u@\h \W]$PS1"
+fi;
Signature · 1 line
2.4.3
#1 lore raw

PATCH v2 1/1 bash: add default bash settings

David,

Quoted 16 lines · David Van Arnem

Settings that were bash-specific were previously removed from system/skeleton/etc/profile. This measn that users using bash no longer get the "normal" bash prompt with [user at host dir]#/$, and only get #/$. This commit adds back the bash-specific settings, but adds them to the bash package so they are only used when bash is installed on the target system.

bash_profile.sh contains the variables, aliases, and color profile that were previously in system/skeleton/etc/profile. The changes to bash.mk use a post-install hook to install bash_profile.sh to the target filesystem, where it will later be sourced by /etc/profile when a bash shell is started.
---
Changes v1 -> v2
- only export PS1 variable for bash_profile.sh

Quoted 1 line

Having this or that shell prompt is really a user-specific choice/configuration. You can already customize that very easily by keeping this bash_profile.sh file in your rootfs overlay.

Therefore, I don't think it's really useful to have such customization by default in Buildroot, and I prefer to not take this patch.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#2 lore raw

PATCH v2 1/1 bash: add default bash settings

David, Thomas, All,

On 2015-12-20 15:27 +0100, Thomas Petazzoni spake thusly:

Quoted 17 lines · David Van Arnem
Quoted 16 lines

Settings that were bash-specific were previously removed from system/skeleton/etc/profile. This measn that users using bash no longer get the "normal" bash prompt with [user at host dir]#/$, and only get #/$. This commit adds back the bash-specific settings, but adds them to the bash package so they are only used when bash is installed on the target system.

bash_profile.sh contains the variables, aliases, and color profile that were previously in system/skeleton/etc/profile. The changes to bash.mk use a post-install hook to install bash_profile.sh to the target filesystem, where it will later be sourced by /etc/profile when a bash shell is started.
---
Changes v1 -> v2
- only export PS1 variable for bash_profile.sh

Quoted 8 lines
Quoted 1 line

Having this or that shell prompt is really a user-specific choice/configuration. You can already customize that very easily by keeping this bash_profile.sh file in your rootfs overlay.

Therefore, I don't think it's really useful to have such customization by default in Buildroot, and I prefer to not take this patch.

I side with Thomas: this really is a user customisation, so belongs to a rootfs overlay (or a post-build script).

I'll mark this patch as rejected in Patchwork.

Thanks! :-)

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'