1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-04-24 17:03:22 -07:00

localize iterator variables

see commit 7d895d2
This commit is contained in:
Connor Olding 2022-03-06 13:12:17 -08:00
parent 90038bf996
commit eaa94d66b9
13 changed files with 15 additions and 8 deletions

3
sh/aur
View File

@ -50,7 +50,7 @@ aur() { ### @-
# TODO: option to auto install dependencies
local built=
local built= p=
for p in "$@"; do
cd "$bd"
local download_fail=0
@ -115,6 +115,7 @@ aur() { ### @-
fi
done
local recent=
cd "$bd"
if [ -n "$built" ] && [ $o_install -eq 1 ]; then
if [ $o_all_at_once -eq 1 ]; then

3
sh/bak
View File

@ -20,8 +20,7 @@ bak() { ### @-
### -rw-r--r-- 1 notwa None 0 Dec 25 2001 butts.bak.bak
### ```
[ $# -gt 0 ] || { printf "%s\n" "$0: too few arguments" >&2; return 1; }
local ret=0
local f=
local ret=0 f=
for f; do
if [ -e "$f.bak" ]; then
bak "$f.bak" || { ret=1; continue; }

View File

@ -16,7 +16,7 @@ baknow() { ### @- backup files by appending their timestamps given by [`now`.](#
### -rw-r--r-- 1 notwa None 0 Dec 25 2001 butts.2001-12-26_01800000.bak
### ```
argc $# -ge 1 "$0" || return
local ret=0
local ret=0 f=
for f; do
cp -ip "$f" "$f.$(now "$f").bak" || ret=1
done

View File

@ -19,7 +19,7 @@ baks() { ### @-
### -rw-r--r-- 1 notwa None 0 Dec 25 2001 butts.21-08-01_14-54-07.bak
### -rw-r--r-- 1 notwa None 0 Dec 25 2001 butts.21-08-01_14-54-09.bak
### ```
local ret=0
local ret=0 fp=
for fp; do
local now="$(date -u '+%y-%m-%d_%H-%M-%S')"
local bak="$fp.$now.bak"

View File

@ -6,6 +6,7 @@
colors2() {
[ $# -eq 0 ] || { printf "%s\n" "$0: does not take arguments" >&2; return 1; }
local a= b= i= j=
for a in 0 60; do
for j in 40 41 43 42 46 44 45 47; do
printf ' \033[%s;%sm %03d \033[m' '48;5;16' $((a+j-10)) $((a+j))

View File

@ -90,6 +90,8 @@ compile() { ### @-
local clang="$(whence -p clang 2>/dev/null)"
local clang_flags=() # currently just for clang-msvc
local flag= d= # iterator variables
local cl= vc=
if [ -n "$MSYSTEM" ]; then # using msys2?
if [ -z "$clang" ]; then # don't have native clang?

View File

@ -125,6 +125,7 @@ document1() {
# first section:
printf '\n## %s\n' 'shell functions' >> "$out" || return 5
local f=
for f in sh/*; do
[ -e "$f" ] || continue # make sure glob went through

View File

@ -8,7 +8,7 @@
# probably not compatible with busybox ps because its column 2 isn't PID.
running() { ### @- WIP
local cmd=0 pid=0
local cmd=0 pid=0 col=
local usage='usage: running {cmd|pid} ...'
[ $# -gt 0 ] || { printf '%s\n' "$usage" >&2; return 2; }
for col; do

2
sh/sc
View File

@ -53,7 +53,7 @@ sc() { ### @-
return 1
}
local clipboard=""
local clipboard="" f=
for f; do
f="$(readlink -f "$f")"
if [ ! -e "$f" ]; then

View File

@ -10,6 +10,7 @@ slit() { ### @-
### view specific columns of text.
[ $# -gt 0 ] \
|| { printf '%s: too few arguments\n' "$0" >&2; return 1; }
local arg=
for arg; do
[ "$arg" -ge 0 ] 2>/dev/null \
|| { printf '%s: not a nonnegative integer: %s\n' "$0" "$arg"; return 1; };

View File

@ -11,6 +11,7 @@ slitt() { ### @-
### this version of `slit` uses tabs for its field separators.
[ $# -gt 0 ] \
|| { printf '%s: too few arguments\n' "$0" >&2; return 1; }
local arg=
for arg; do
[ "$arg" -ge 0 ] 2>/dev/null \
|| { printf '%s: not a nonnegative integer: %s\n' "$0" "$arg"; return 1; };

2
sh/sum
View File

@ -14,7 +14,7 @@ sum() { ### @-
### ```
###
### **TODO:** consider renaming because sum(1) already exists.
local sum=0
local sum=0 i=
for i; do
i="${i%,}"
: $((sum+=i))

1
sh/wat
View File

@ -11,6 +11,7 @@ wat() { ### @-
###
### written by [leah2.](https://leahneukirchen.org/)
( # constrain unalias
local cmd=
for cmd; do
if (( $+aliases[$cmd] )); then
printf '%s: aliased to %s\n' $cmd $aliases[$cmd]