fix: POSIX does not support head byte count

Test done on OpenBSD for compatibility with the POSIX specification,
also becoming a new supported system.
This commit is contained in:
Ben Grande 2024-04-23 18:34:10 +02:00
parent a179b8c878
commit 9954972df3
No known key found for this signature in database
GPG Key ID: 00C64E14F51F9E56
8 changed files with 20 additions and 9 deletions

View File

@ -28,7 +28,7 @@ Configuration and scripts targeting:
- Portability:
- POSIX compliant code
- Drop-in configuration files
- Tested in Qubes OS Dom0, Debian, Fedora
- Tested in Qubes OS Dom0, Debian, Fedora, OpenBSD
- Tasks:
- GUI: x11, gtk
- SCM: git, tig, git-shell

View File

@ -77,7 +77,7 @@
; Signed tags and commits
stag = "!sh -c '\
commit_id=\"$(git rev-parse --verify \"$@\")\"; \
tag_name=\"signed_tag_for_$(echo $commit_id | head -c 8)\"; \
tag_name=\"signed_tag_for_$(echo $commit_id | cut -c 1-8)\"; \
git tag -s \"$tag_name\" \
-m \"Tag for commit $commit_id\" \"$commit_id\"; \
echo \"$tag_name\"'" -

View File

@ -39,7 +39,7 @@ chmod -R 0755 "$git_home/git-shell-commands"
git config --system receive.updateServerInfo true
git config --system receive.advertisePushOptions true
nonce="$(head /dev/urandom | LC_ALL=C tr -dc 'A-Za-z0-9!#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~' | head -c 256)"
nonce="$(head /dev/urandom | LC_ALL=C tr -dc 'A-Za-z0-9!#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~' | cut -c 1-256)"
git config --system receive.certNonceSeed "$nonce"
chown -R "$git_user":"$git_user" "$git_home"

View File

@ -46,7 +46,7 @@ _reset_line() {
local termios cur_y
## Ask the terminal for any pending (line buffered) input.
termios=$(stty --save) && stty -icanon && stty "$termios"
termios=$(stty -g) && stty -icanon && stty "$termios"
## On pending input, assume it's been echoed and we're not in first column.
## Otherwise ask the terminal for current column and read it from input.
if read -t 0 || {

View File

@ -94,12 +94,19 @@ KDEHOME="$XDG_CONFIG_HOME/kde"
#KDEROOTHOME="/root/.config/kde"
INPUTRC="$BASHDIR/inputrc"
if has less; then
if test "$(less -V | awk -F '[ .]' 'NR==1 {print $2}')" -ge 582; then
lesskey_src=0
less_version="$(less -V | awk -F '[ .]' 'NR==1 {print $2}')"
case "${less_version}" in
""|*[!0-9]*) ;;
*) if test "${less_version}" -ge 582; then lesskey_src=1; fi;;
esac
if test "${lesskey_src}" = "1"; then
LESSKEY="$XDG_CONFIG_HOME/less/lesskey"
elif has lesskey; then
LESSKEY="$XDG_CONFIG_HOME/less/lesskey-old"
lesskey -o "$LESSKEY" "$XDG_CONFIG_HOME/less/lesskey"
fi
unset lesskey_src less_version
fi
export GTK2_RC_FILES KDEHOME KDEROOTHOME INPUTRC LESSKEY

View File

@ -38,7 +38,9 @@ if has lsblk; then
alias lsblk='lsblk -o $_lsblk_options'
alias lsblku='lsblk -o $_lsblk_options,UUID,PARTUUID'
fi
if ! grep --color 2>&1 | grep -q "unrecognized option"; then
if ! grep --color 2>&1 | grep -qE "(unrecognized|unknown) option" &&
! grep --exclude 2>&1 | grep -qE "(unrecognized|unknown) option"
then
alias grep="grep --exclude='.*.swp' --exclude='*~' --color=auto"
fi
alias fgrep="grep -F"
@ -210,7 +212,7 @@ _git_prompt_info(){
fi
ref="$(git symbolic-ref HEAD 2>/dev/null | cut -d '/' -f3)"
test "${ref-}" || ref="$(git describe --tags --exact-match HEAD 2>/dev/null)"
test "${ref-}" || ref="$(git rev-parse HEAD 2>/dev/null | head -c 7)"
test "${ref-}" || ref="$(git rev-parse HEAD 2>/dev/null | cut -c 1-7)"
test "${ref-}" || return
# shellcheck disable=2039,3003
case "${TERM-}" in

View File

@ -8,5 +8,7 @@
## some distributions such as Qubes, Whonix, Debian, Gentoo ship files to
## /etc/profile.d.
emulate sh -c "source /etc/profile"
if test -r /etc/profile; then
emulate sh -c "source /etc/profile"
fi
. "$HOME/.profile"

View File

@ -71,7 +71,7 @@ if test "${color_prompt-}" = "yes"; then
autoload -U colors && colors
[[ "${COLORTERM-}" == (24bit|truecolor) || "${terminfo[colors]}" -eq '16777216' ]] || zmodload zsh/nearcolor
PS1="\$(resize-terminal)%F{magenta}[%{$usercolor%}%n@%M%F{reset_color%} %{$dircolor%}%50<...<%~%<<%F{reset_color%}\$(_git_prompt_info)%F{magenta}]%F{reset_color}${newline-}${ps1_symbol} "
PS1="\$(resize-terminal)%F{magenta}[%{$usercolor%}%n@%m%F{reset_color%} %{$dircolor%}%50<...<%~%<<%F{reset_color%}\$(_git_prompt_info)%F{magenta}]%F{reset_color}${newline-}${ps1_symbol} "
RPS1="%(?..(%{"$'\e[31m'"%}%?%{$reset_color%}%)%<<)"
else
PS1="\$(resize-terminal)[%n@%M %~\$(_git_prompt_info)]${newline}${ps1_symbol} "