[wiki] [sites] [surf] Removed function keywords from shell scripts for POSIX compliance. || Aidan Hall

From: <git_AT_suckless.org>
Date: Sun, 21 Mar 2021 19:24:30 +0100

commit 480e2696648abd9ed758c580816c343f41dd8abc
Author: Aidan Hall <aidan.hall_AT_outlook.com>
Date: Sun Mar 21 18:11:29 2021 +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.

diff --git a/surf.suckless.org/patches/externalpipe-signal/externalpipe_buffer.sh b/surf.suckless.org/patches/externalpipe-signal/externalpipe_buffer.sh
index 67eb13c2..48787764 100755
--- a/surf.suckless.org/patches/externalpipe-signal/externalpipe_buffer.sh
+++ b/surf.suckless.org/patches/externalpipe-signal/externalpipe_buffer.sh
_AT_@ -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:]'
_AT_@ -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 "
"}' |
     xmllint --html --xpath "//*" - |
     awk '{ gsub("<[^>]*>", ""); print($0); }' |
_AT_@ -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
_AT_@ -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/↵/
/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/↵/
/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
index 2fe11384..b0776200 100755
--- a/surf.suckless.org/patches/externalpipe/surf_linkselect.sh
+++ b/surf.suckless.org/patches/externalpipe/surf_linkselect.sh
_AT_@ -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;
 
_AT_@ -37,7 +37,7 @@ function dump_links_with_titles() {
   }'
 }
 
-function link_normalize() {
+link_normalize() {
   URI=$1
   awk -v uri=$URI '{
     gsub("&amp;", "\&");
_AT_@ -62,7 +62,7 @@ function link_normalize() {
   }'
 }
 
-function link_select() {
+link_select() {
   tr '
' ' ' |
     xmllint --html --xpath "//a" - |
     dump_links_with_titles |
_AT_@ -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
Received on Sun Mar 21 2021 - 19:24:30 CET

This archive was generated by hypermail 2.3.0 : Sun Mar 21 2021 - 19:24:48 CET