Skip to content
Myr

make lint: Perform bash script linting

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent de0df24 · Browse files · 8 files+83 added−48 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

8 files+83 added−48 removed

  • other:+83 added−48 removed

8 files+83 added−48 removed

modified:shell/completion.bash+3 added-1 removed
29 unmodified lines
30# }3132###########################################################3334#----BEGIN shfmt35#----BEGIN INCLUDE common.sh36# NOTE: Do not directly edit this section, which is copied from "common.sh".36# To modify it, one can edit "common.sh" and run "./update-common.sh" to apply37# To modify it, one can edit "common.sh" and run "./update.sh" to apply38# the changes. See code comments in "common.sh" for the implementation details.3940__fzf_defaults() {41 printf '%s\n' "--height ${FZF_TMUX_HEIGHT:-40%} --min-height 20+ --bind=ctrl-z:ignore $1"
641 unmodified lines
683 *) __fzf_defc "$cmd" "$fn" "-o default -o bashdefault" ;;684 esac685 done686}687#----END shfmt688689fi
modified:shell/completion.zsh+1 added-1 removed
96 unmodified lines
97###########################################################9899#----BEGIN INCLUDE common.sh100# NOTE: Do not directly edit this section, which is copied from "common.sh".101# To modify it, one can edit "common.sh" and run "./update-common.sh" to apply101# To modify it, one can edit "common.sh" and run "./update.sh" to apply102# the changes. See code comments in "common.sh" for the implementation details.103104__fzf_defaults() {105 printf '%s\n' "--height ${FZF_TMUX_HEIGHT:-40%} --min-height 20+ --bind=ctrl-z:ignore $1"
367 unmodified lines
modified:shell/key-bindings.bash+3 added-1 removed
modified:shell/key-bindings.zsh+1 added-1 removed
38 unmodified lines
39if [[ -o interactive ]]; then4041#----BEGIN INCLUDE common.sh42# NOTE: Do not directly edit this section, which is copied from "common.sh".43# To modify it, one can edit "common.sh" and run "./update-common.sh" to apply43# To modify it, one can edit "common.sh" and run "./update.sh" to apply44# the changes. See code comments in "common.sh" for the implementation details.4546__fzf_defaults() {47 printf '%s\n' "--height ${FZF_TMUX_HEIGHT:-40%} --min-height 20+ --bind=ctrl-z:ignore $1"
115 unmodified lines
deleted:shell/update-common.sh-31 removed
added:shell/update.sh+67 added
1#!/usr/bin/env bash23# This script applies the contents of "common.sh" to the other files.45set -e67dir=${0%"${0##*/}"}89update() {10 {11 sed -n '1,/^#----BEGIN INCLUDE common\.sh/p' "$1"12 cat <<EOF13# NOTE: Do not directly edit this section, which is copied from "common.sh".14# To modify it, one can edit "common.sh" and run "./update.sh" to apply15# the changes. See code comments in "common.sh" for the implementation details.16EOF17 grep -v '^[[:blank:]]*#' "$dir/common.sh" # remove code comments in common.sh18 sed -n '/^#----END INCLUDE/,$p' "$1"19 } > "$1.part"2021 mv -f "$1.part" "$1"22}2324update "$dir/completion.bash"25update "$dir/completion.zsh"26update "$dir/key-bindings.bash"27update "$dir/key-bindings.zsh"2829# Check if --check is in ARGV30check=031rest=()32for arg in "$@"; do33 case $arg in34 --check) check=1 ;;35 *) rest+=("$arg") ;;36 esac37done3839fmt() {40 if ! grep -q "^#----BEGIN shfmt" "$1"; then41 if [[ $check == 1 ]]; then42 shfmt -d "$1"43 return $?44 else45 shfmt -w "$1"46 fi47 else48 {49 sed -n '1,/^#----BEGIN shfmt/p' "$1" | sed '$d'50 sed -n '/^#----BEGIN shfmt/,/^#----END shfmt/p' "$1" | shfmt --filename "$1"51 sed -n '/^#----END shfmt/,$p' "$1" | sed '1d'52 } > "$1.part"5354 if [[ $check == 1 ]]; then55 diff -q "$1" "$1.part"56 ret=$?57 rm -f "$1.part"58 return $ret59 fi6061 mv -f "$1.part" "$1"62 fi63}6465for file in "${rest[@]}"; do66 fmt "$file" || exit $?67done
modified:.tool-versions+2 added-1 removed
1golang 1.232ruby 3.42ruby 3.43shfmt 3.12
modified:Makefile+6 added-12 removed
8 unmodified lines
9 $(ROOT_DIR)/bin/fzf-tmux \10 $(ROOT_DIR)/install \11 $(ROOT_DIR)/uninstall \12 $(ROOT_DIR)/shell/common.sh \13 $(ROOT_DIR)/shell/update-common.sh14BASH_SCRIPTS_INDENT_LEFT := $(ROOT_DIR)/shell/completion.bash \15 $(ROOT_DIR)/shell/key-bindings.bash13 $(ROOT_DIR)/shell/update.sh \14 $(ROOT_DIR)/shell/completion.bash \15 $(ROOT_DIR)/shell/key-bindings.bash1617ifdef FZF_VERSION18VERSION := $(FZF_VERSION)19else
79 unmodified lines
99100lint: $(SOURCES) test/*.rb test/lib/*.rb ${BASH_SCRIPTS}101 [ -z "$$(gofmt -s -d src)" ] || (gofmt -s -d src; exit 1)102 bundle exec rubocop -a --require rubocop-minitest --require rubocop-performance103 [ -z "$$(shfmt -d $(BASH_SCRIPTS))" ] || (echo "format bash files by (make fmt)"; exit 1)103 shell/update.sh --check ${BASH_SCRIPTS}104105fmt: $(SOURCES) $(BASH_SCRIPTS) $(BASH_SCRIPTS_INDENT_LEFT)105fmt: $(SOURCES) $(BASH_SCRIPTS)106 gofmt -s -w src107 shfmt -w $(BASH_SCRIPTS)108 # shift left because we have an outermost if block for historical reasons.109 for f in $(BASH_SCRIPTS_INDENT_LEFT); do \110 shfmt -w "$$f"; \111 tmp=$$(mktemp); \112 sed 's/^ //' "$$f" > "$$tmp" && mv "$$tmp" "$$f"; \113 done107 shell/update.sh ${BASH_SCRIPTS}108109install: bin/fzf110111generate:
95 unmodified lines