Skip to content

Commit 9387225

Browse files
authored
Guard against undefined variables when PS1 is evaluated (#1020)
* Guard against undefined variables when PS1 is evaluated * Update version in devcontainer-feature.json
1 parent 0356cbb commit 9387225

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/common-utils/devcontainer-feature.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "common-utils",
3-
"version": "2.4.3",
3+
"version": "2.4.4",
44
"name": "Common Utilities",
55
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/common-utils",
66
"description": "Installs a set of common command line utilities, Oh My Zsh!, and sets up a non-root user.",
@@ -66,4 +66,4 @@
6666
"description": "Add packages from non-free Debian repository? (Debian only)"
6767
}
6868
}
69-
}
69+
}

src/common-utils/scripts/bash_theme_snippet.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
# bash theme - partly inspired by https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/robbyrussell.zsh-theme
33
__bash_prompt() {
44
local userpart='`export XIT=$? \
5-
&& [ ! -z "${GITHUB_USER}" ] && echo -n "\[\033[0;32m\]@${GITHUB_USER} " || echo -n "\[\033[0;32m\]\u " \
5+
&& [ ! -z "${GITHUB_USER:-}" ] && echo -n "\[\033[0;32m\]@${GITHUB_USER:-} " || echo -n "\[\033[0;32m\]\u " \
66
&& [ "$XIT" -ne "0" ] && echo -n "\[\033[1;31m\]➜" || echo -n "\[\033[0m\]➜"`'
77
local gitbranch='`\
88
if [ "$(git config --get devcontainers-theme.hide-status 2>/dev/null)" != 1 ] && [ "$(git config --get codespaces-theme.hide-status 2>/dev/null)" != 1 ]; then \
9-
export BRANCH=$(git --no-optional-locks symbolic-ref --short HEAD 2>/dev/null || git --no-optional-locks rev-parse --short HEAD 2>/dev/null); \
10-
if [ "${BRANCH}" != "" ]; then \
11-
echo -n "\[\033[0;36m\](\[\033[1;31m\]${BRANCH}" \
9+
export BRANCH="$(git --no-optional-locks symbolic-ref --short HEAD 2>/dev/null || git --no-optional-locks rev-parse --short HEAD 2>/dev/null)"; \
10+
if [ "${BRANCH:-}" != "" ]; then \
11+
echo -n "\[\033[0;36m\](\[\033[1;31m\]${BRANCH:-}" \
1212
&& if [ "$(git config --get devcontainers-theme.show-dirty 2>/dev/null)" = 1 ] && \
1313
git --no-optional-locks ls-files --error-unmatch -m --directory --no-empty-directory -o --exclude-standard ":/*" > /dev/null 2>&1; then \
1414
echo -n " \[\033[1;33m\]✗"; \

0 commit comments

Comments
 (0)