1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-05-20 10:53:23 -07:00

always use local var= instead of local var

blame zsh
This commit is contained in:
Connor Olding 2021-09-30 08:43:40 -07:00
parent 3e9e80de15
commit 5382da0605
9 changed files with 29 additions and 31 deletions

View File

@ -48,7 +48,7 @@ autoload history-search-end
zmodload zsh/mathfunc
function {
local a b
local a= b=
# combine everything matching "YES_ZSH" in ~/sh/ into ~/.sh,
# but only recompile the output if the sha1sum has changed.

View File

@ -12,7 +12,7 @@ archive() {
# Matt Hamilton <m@tthamilton.com>
#
local archive_name path_to_archive _gzip_bin _bzip2_bin _xz_bin _zstd_bin
local archive_name= path_to_archive= _gzip_bin= _bzip2_bin= _xz_bin= _zstd_bin=
if (( $# < 2 )); then
cat >&2 <<EOF

View File

@ -15,7 +15,7 @@ busiest() { ### @-
### 21042 play
### ```
[ $# -le 0 ] || { printf "%s\n" "$0: too many arguments" >&2; return 1; }
local c d
local c= d=
for d in *(FDN); do
print $(find $d 2>/dev/null | wc -l) $d
done | sort -nr | while read c d; do

View File

@ -90,18 +90,17 @@ compile() { ### @-
local clang="$(whence -p clang 2>/dev/null)"
local clang_flags=() # currently just for clang-msvc
local cl
local vc
local cl= vc=
if [ -n "$MSYSTEM" ]; then # using msys2?
if [ -z "$clang" ]; then # don't have native clang?
# then maybe we have clang-msvc installed.
local dir
local dir=
printf "%s\n" "/c/Program Files/LLVM"*(On/N[1]) | read -r dir
if [ -d "$dir" ] && [ -e "$dir/bin/clang" ]; then
clang="$dir/bin/clang"
# not sure if i'll need this:
#local clang_include
#local clang_include=
#printf "%s\n" "$dir/lib/clang/"*(On/N[1]) | read -r clang_include
#[ -n "$clang_include" ] || { echo "failed glob; missing clang include" >&2; return 1 }
#clang_flags+=(-I"$clang_include/include")
@ -110,7 +109,7 @@ compile() { ### @-
fi
fi
local winkit
local winkit=
printf "%s\n" "/c/Program Files (x86)/Windows Kits/"*(on/N[1]) | read -r winkit
[ -z "$winkit" ] || printf "%s\n" "$winkit/Lib/"*(On/N[1]) | read -r winkit
@ -119,9 +118,7 @@ compile() { ### @-
:
else
# detect MSVC.
local clarch
local arch
local msvc_dig_deep
local clarch= arch= msvc_dig_deep=
[ "$MSYSTEM" = MINGW64 ] && clarch="/amd64" || clarch=""
[ "$MSYSTEM" = MINGW64 ] && arch="x64" || arch="x86"
if [ -d "/c/Program Files (x86)/Microsoft Visual Studio" ]; then # 2017+
@ -179,9 +176,9 @@ compile() { ### @-
fi
# set some defaults.
local sepples=0
[ -n "$clang" ] && local CC=clang || local CC=gcc
[ -n "$clang" ] && local CXX=clang++ || local CXX=g++
local sepples=0 CC= CXX=
[ -n "$clang" ] && CC=clang || CC=gcc
[ -n "$clang" ] && CXX=clang++ || CXX=g++
local our_flags=(-I.)
# guess if we're compiling C++ by the file extension.
@ -263,10 +260,11 @@ compile() { ### @-
fi
fi
local gold=
# utilize clang's vast debugging and hardening features where available.
if [ $CC = clang ]; then
debug_flags+=(-ftrapv)
[ -z "$MSYSTEM" ] && local gold=gold || local gold=lld
[ -z "$MSYSTEM" ] && gold=gold || gold=lld
[ -n "$MSYSTEM" ] && our_flags+=(-fansi-escape-codes) || true
if [ $clang_msvc -eq 1 ] || [ -z "$MSYSTEM" ]; then
debug_flags+=(-fsanitize=undefined) # this SHOULD work with mingw,
@ -302,9 +300,7 @@ compile() { ### @-
# allow multiple source files (using the firstmost to determine the program name)
# by generating a file that #includes each given file.
local final_flags=()
local libraries=()
local warnings=()
local final_flags=() libraries=() warnings=()
for flag in $our_flags $flags; do
# move -l flags to the end because gcc won't respect them otherwise.
if [[ $flag == -l* ]]; then

View File

@ -69,7 +69,7 @@ document2() {
esac
if [ -n "$n" ]; then
local url
local url=
# different subdirs need to be handled differently:
[ "$f" != "${f#sh/}" ] && url="/sh/${f#sh/}#L$c" || url="/home/${f#.}#L$c"
if [ "$n" = "$e" ]; then
@ -117,7 +117,7 @@ document1() {
# create new output file (with a tilde as not to overwrite just yet):
: > "$out" || return 4
local line
local line=
if [ -f "$in_" ]; then
# copy existing lines up to (and including) the "DOCUMENT" marker:

View File

@ -12,7 +12,7 @@ lsarchive() {
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
local verbose
local verbose=
if (( $# == 0 )); then
cat >&2 <<EOF

View File

@ -9,7 +9,7 @@ maybesudo_() { ### @-
### as it stands, this mostly just handles some environment variables.
###
### try this: `maybesudo_ -u "$USER" printenv`
local name
local name=
local env_cleanup=0
while getopts :AEHKPSVbhiklnsvC:U:g:p:r:t:u: name; do
case $name in
@ -82,8 +82,10 @@ maybesudo_() { ### @-
# just export the bare minimum that a fairly stock sudo would.
# $path is special in zsh, so call it pathy instead.
local colors display dpkg_colors home hostname krb5ccname \
ls_colors pathy ps1 ps2 user username xauthority xauthorization
local \
colors= display= dpkg_colors= home= hostname= krb5ccname= \
ls_colors= pathy= ps1= ps2= user= username= xauthority= \
xauthorization=
[ -z "$COLORS" ] || colors=COLORS="$COLORS"
[ -z "$DISPLAY" ] || display=DISPLAY="$DISPLAY"

View File

@ -31,7 +31,7 @@ minutemaid() { ### @-
### echo this will never happen
### ```
local offset=0 name
local offset=0 name=
while getopts 'o:h' name; do
case $name in
o) offset="$OPTARG";;

View File

@ -12,12 +12,12 @@ unarchive() {
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
local remove_archive
local success
local file_name
local file_path
local extract_dir
local _gzip_bin _bzip2_bin _xz_bin _zstd_bin
local remove_archive=
local success=
local file_name=
local file_path=
local extract_dir=
local _gzip_bin= _bzip2_bin= _xz_bin= _zstd_bin=
if (( $# == 0 )); then
cat >&2 <<EOF