commit 480e2696648abd9ed758c580816c343f41dd8abc
parent 767d7a0500d4b326e76bb20ea8633d1ce2ded679
Author: Aidan Hall <aidan.hall@outlook.com>
Date: Sun, 21 Mar 2021 18:11:29 +0000
[surf] Removed function keywords from shell scripts for POSIX compliance.
Using the 'function' keyword to denote a function is a Bash extension.
I have removed its use from the surf_linkselect.sh and
externalpipe_buffer.sh scripts.
Diffstat:
2 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/surf.suckless.org/patches/externalpipe-signal/externalpipe_buffer.sh b/surf.suckless.org/patches/externalpipe-signal/externalpipe_buffer.sh
@@ -3,7 +3,7 @@
# Input Usage: echo st or surf content from externalpipe | ./externalpipe_buffer.sh {st,surf}_strings_read
# Menus Usage: ./externalpipe_buffer.sh dmenu_{copy, type}
BUFFER_FILE=/tmp/content_buffer
-function st_strings_read() {
+st_strings_read() {
INPUT="$(cat)"
echo "$(
echo "$INPUT" | grep -Eo '\S+' | tr -d '[:blank:]'
@@ -12,7 +12,7 @@ function st_strings_read() {
)" | uniq | grep . | awk '{ print length, $0 }' | sort -n -s | cut -d" " -f2- \
>> $BUFFER_FILE &
}
-function surf_strings_read() {
+surf_strings_read() {
awk '{printf "%sNEWLINE_REPLACE", $0} END {printf "\n"}' |
xmllint --html --xpath "//*" - |
awk '{ gsub("<[^>]*>", ""); print($0); }' |
@@ -23,7 +23,7 @@ function surf_strings_read() {
uniq | grep . | awk '{ print length, $0 }' | sort -n -s | cut -d" " -f2- \
>> $BUFFER_FILE &
}
-function trigger_sigusr1() {
+trigger_sigusr1() {
USE_FIFO=F # Recomended as T but only if using dmenu-stdin patch w/ FIFO
rm -f $BUFFER_FILE
if [ $USE_FIFO == T ]; then mkfifo $BUFFER_FILE; else touch $BUFFER_FILE; fi
@@ -31,15 +31,15 @@ function trigger_sigusr1() {
pkill -USR1 "^st$" &
if [ $USE_FIFO != T ]; then sleep 0.8; fi
}
-function dmenu_copy() {
+dmenu_copy() {
trigger_sigusr1
cat $BUFFER_FILE | dmenu -l 10 -i -w $(xdotool getactivewindow) -p 'Screen Copy' | sed 's/↵/\n/g' | xclip -i
}
-function dmenu_type() {
+dmenu_type() {
trigger_sigusr1
cat $BUFFER_FILE | dmenu -l 10 -i -w $(xdotool getactivewindow) -p 'Screen Type' | sed 's/↵/\n/g' | xargs -IC xdotool type --delay 0 "C"
}
-function pipe_combine() {
+pipe_combine() {
trigger_sigusr1
cat - $BUFFER_FILE
}
diff --git a/surf.suckless.org/patches/externalpipe/surf_linkselect.sh b/surf.suckless.org/patches/externalpipe/surf_linkselect.sh
@@ -10,7 +10,7 @@
SURF_WINDOW="${1:-$(xprop -root | sed -n '/^_NET_ACTIVE_WINDOW/ s/.* //p')}"
DMENU_PROMPT="${2:-Link}"
-function dump_links_with_titles() {
+dump_links_with_titles() {
awk '{
input = $0;
@@ -37,7 +37,7 @@ function dump_links_with_titles() {
}'
}
-function link_normalize() {
+link_normalize() {
URI=$1
awk -v uri=$URI '{
gsub("&", "\\&");
@@ -62,7 +62,7 @@ function link_normalize() {
}'
}
-function link_select() {
+link_select() {
tr '\n\r' ' ' |
xmllint --html --xpath "//a" - |
dump_links_with_titles |
@@ -73,4 +73,4 @@ function link_select() {
link_normalize $(xprop -id $SURF_WINDOW _SURF_URI | cut -d '"' -f 2)
}
-link_select-
\ No newline at end of file
+link_select