mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-07 21:16:57 +02:00
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>
25 lines
913 B
Plaintext
25 lines
913 B
Plaintext
# 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
|