mirror of
https://github.com/flatcar/scripts.git
synced 2026-05-04 11:51:14 +02:00
upgrade hook: move PS1 niceties from .bashrc to profile.d
This solves two problems (and half): a) messing with user's preference file is a no-no, if we want a hardcoded behaviour like this, profile.d is the way to go b) .bashrc settings are overridden when doing env-update; source /etc/profile c) profile.d will also apply to root (although not with sudo su) BUG=none TEST=below 1) ./run_chroot_version_hooks --version 21 2) see all fixed, source /etc/profile, and still see my prompt unchanged Change-Id: I25b4602f4951b17815bcd312a8249320784c67e1 Reviewed-on: https://gerrit.chromium.org/gerrit/12539 Reviewed-by: Mike Frysinger <vapier@chromium.org> Tested-by: Zdenek Behan <zbehan@chromium.org> Commit-Ready: Zdenek Behan <zbehan@chromium.org>
This commit is contained in:
parent
1702be631c
commit
49a8e9687f
24
chroot_version_hooks.d/22_trim_bashrc
Normal file
24
chroot_version_hooks.d/22_trim_bashrc
Normal file
@ -0,0 +1,24 @@
|
||||
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
# We used to place bashrc niceties into the user's .bashrc. Use
|
||||
# profile.d instead.
|
||||
|
||||
sudo_clobber /etc/profile.d/chromiumos-niceties.sh << EOF
|
||||
# Niceties for interactive logins. (cr) denotes this is a chroot, the
|
||||
# __git_branch_ps1 prints current git branch in ./ . The $r behavior is to
|
||||
# make sure we don't reset the previous $? value which later formats in
|
||||
# $PS1 might rely on.
|
||||
PS1='\$(r=\$?; __git_branch_ps1 "(%s) "; exit \$r)'"\${PS1}"
|
||||
PS1="(cr) \${PS1}"
|
||||
EOF
|
||||
|
||||
# Also, get rid of the leftover stuff in the user's .bashrc.
|
||||
# These are the two originally added lines:
|
||||
STR1='export PS1='"'"'$(r=$?; __git_branch_ps1 "(%s) "; exit $r)'"'"'"${PS1}"'
|
||||
STR2='export PS1="(cr) ${PS1}"'
|
||||
|
||||
sed -e "/${STR1}/d" -e "/${STR2}/d" -i ~/.bashrc
|
||||
|
||||
exit 0
|
||||
Loading…
x
Reference in New Issue
Block a user