From 582fd3b69868f12fc14f0fbefb81521445b075fa Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 15 Jul 2016 00:05:58 +1200 Subject: Terser `read -rd ''` idiom --- bash/bashrc.d/apf.bash | 2 +- bash/bashrc.d/man.bash | 2 +- bash/bashrc.d/mysql.bash | 2 +- bash/bashrc.d/pass.bash | 2 +- bash/bashrc.d/path.bash | 2 +- bash/bashrc.d/prompt.bash | 4 ++-- bash/bashrc.d/readz.bash | 2 +- bash/bashrc.d/sd.bash | 2 +- bash/bashrc.d/td.bash | 2 +- bash/bashrc.d/ud.bash | 2 +- bash/bashrc.d/vis.bash | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) (limited to 'bash') diff --git a/bash/bashrc.d/apf.bash b/bash/bashrc.d/apf.bash index 8ffa7953..44de3a9e 100644 --- a/bash/bashrc.d/apf.bash +++ b/bash/bashrc.d/apf.bash @@ -85,7 +85,7 @@ apf() { # Read all the null-delimited arguments from the file local -a args local arg - while IFS= read -d '' -r arg ; do + while IFS= read -rd '' arg ; do args[${#args[@]}]=$arg done < "$argfile" diff --git a/bash/bashrc.d/man.bash b/bash/bashrc.d/man.bash index 562b0625..f1762a01 100644 --- a/bash/bashrc.d/man.bash +++ b/bash/bashrc.d/man.bash @@ -18,7 +18,7 @@ _man() { # Read completion results from a subshell and add them to the COMPREPLY # array individually - while IFS= read -d '' -r page ; do + while IFS= read -rd '' page ; do COMPREPLY[${#COMPREPLY[@]}]=$page done < <( diff --git a/bash/bashrc.d/mysql.bash b/bash/bashrc.d/mysql.bash index 6575e096..34debb1c 100644 --- a/bash/bashrc.d/mysql.bash +++ b/bash/bashrc.d/mysql.bash @@ -34,7 +34,7 @@ _mysql() { # Return the names of the .cnf files sans prefix as completions local db - while IFS= read -d '' -r db ; do + while IFS= read -rd '' db ; do COMPREPLY[${#COMPREPLY[@]}]=$db done < <( diff --git a/bash/bashrc.d/pass.bash b/bash/bashrc.d/pass.bash index 28484761..47f9effe 100644 --- a/bash/bashrc.d/pass.bash +++ b/bash/bashrc.d/pass.bash @@ -14,7 +14,7 @@ _pass() # and filter them down to the ones matching the completing word (compgen # doesn't seem to do this properly with a null delimiter) local entry - while IFS= read -d '' -r entry ; do + while IFS= read -rd '' entry ; do COMPREPLY[${#COMPREPLY[@]}]=$entry done < <( diff --git a/bash/bashrc.d/path.bash b/bash/bashrc.d/path.bash index 5f78e20e..e16e6a4a 100644 --- a/bash/bashrc.d/path.bash +++ b/bash/bashrc.d/path.bash @@ -199,7 +199,7 @@ _path() { # Complete with a directory insert|i|append|add|a|check|c|set|s) local dirname - while IFS= read -d '' -r dirname ; do + while IFS= read -rd '' dirname ; do COMPREPLY[${#COMPREPLY[@]}]=$dirname done < <( diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash index 6d90547f..75bb197c 100644 --- a/bash/bashrc.d/prompt.bash +++ b/bash/bashrc.d/prompt.bash @@ -115,7 +115,7 @@ prompt() { # Safely read status with -z --porcelain local line local -i ready modified untracked - while IFS= read -d '' -r line ; do + while IFS= read -rd '' line ; do if [[ $line == [MADRCT]* ]] ; then ready=1 fi @@ -164,7 +164,7 @@ prompt() { # Safely read status with -0 local line local -i modified untracked - while IFS= read -d '' -r line ; do + while IFS= read -rd '' line ; do if [[ $line == '?'* ]] ; then untracked=1 else diff --git a/bash/bashrc.d/readz.bash b/bash/bashrc.d/readz.bash index 78a178b6..910aab4b 100644 --- a/bash/bashrc.d/readz.bash +++ b/bash/bashrc.d/readz.bash @@ -1,4 +1,4 @@ # Call read with a null delimiter readz() { - builtin read -d '' -r "$@" + builtin read -rd '' "$@" } diff --git a/bash/bashrc.d/sd.bash b/bash/bashrc.d/sd.bash index b65d207d..9d1063d6 100644 --- a/bash/bashrc.d/sd.bash +++ b/bash/bashrc.d/sd.bash @@ -118,7 +118,7 @@ _sd() { [[ $PWD != / ]] || return 1 # Build list of matching sibiling directories - while IFS= read -d '' -r dirname ; do + while IFS= read -rd '' dirname ; do COMPREPLY[${#COMPREPLY[@]}]=$dirname done < <( diff --git a/bash/bashrc.d/td.bash b/bash/bashrc.d/td.bash index d7200c87..9f47c973 100644 --- a/bash/bashrc.d/td.bash +++ b/bash/bashrc.d/td.bash @@ -2,7 +2,7 @@ _td() { local dir dir=${TODO_DIR:-$HOME/Todo} - while IFS= read -d '' -r fn ; do + while IFS= read -rd '' fn ; do COMPREPLY[${#COMPREPLY[@]}]=$fn done < <( shopt -s extglob nullglob diff --git a/bash/bashrc.d/ud.bash b/bash/bashrc.d/ud.bash index 0e01dfd0..2bed481b 100644 --- a/bash/bashrc.d/ud.bash +++ b/bash/bashrc.d/ud.bash @@ -57,7 +57,7 @@ _ud() { # Iterate through directories, null-separated, add them to completions local dirname - while IFS= read -d '' -r dirname ; do + while IFS= read -rd '' dirname ; do COMPREPLY[${#COMPREPLY[@]}]=$dirname done < <( diff --git a/bash/bashrc.d/vis.bash b/bash/bashrc.d/vis.bash index 0a0d861e..17c89ca8 100644 --- a/bash/bashrc.d/vis.bash +++ b/bash/bashrc.d/vis.bash @@ -4,7 +4,7 @@ _vis() { local vispath vispath=${VISPATH:-$HOME/.local/bin} [[ -d $vispath ]] || return - while IFS= read -d '' -r executable ; do + while IFS= read -rd '' executable ; do COMPREPLY[${#COMPREPLY[@]}]=$executable done < <( shopt -s dotglob nullglob -- cgit v1.2.3