mons icon indicating copy to clipboard operation
mons copied to clipboard

Add mons to the FreeBSD ports

Open 0mp opened this issue 5 years ago • 4 comments

Hi there,

we are adding mons to the FreeBSD ports at the moment (https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=222206) and there are some problems with some hard-coded paths. Would you mind if I submit fixes that make the installation process a little bit more general? It should not be too long/intrusive.

0mp avatar Dec 05 '18 17:12 0mp

Thanks @0mp for the feedback and your proposal. Feel free to pull request !

Ventto avatar Jan 11 '19 10:01 Ventto

@Ventto Cool! I'll send some patches if I happen to work on that port again. :+1:

0mp avatar Jan 11 '19 10:01 0mp

So we have a FreeBSD port now — thanks! There are some GNU sed assumptions in libshlist that break it, though. E.g., the sed i command does not work the same in BSD sed as GNU sed, which breaks list_insert:

$ echo 1 2 3 | sed '1ifoobar'     # BSD sed
sed: 1: "1ifoobar": command i expects \ followed by text

$ echo 1 2 3 | gsed '1ifoobar'   # GNU sed
foobar
1 2 3

$ echo 1 2 3 | sed '1i\
foobar '          # BSD sed again
foobar 1 2 3

Aliasing sed to gsed on FreeBSD (and adding a port dependency on gsed) fixes it; currently I've hacked in a:

sed() {
  gsed "$@"
}

definition to my copy of mons so that it works.

Edit: tracking in https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=248632 .

cemeyer avatar Aug 12 '20 17:08 cemeyer

I suspect the answer to this is something like:

diff --git a/liblist.sh b/liblist.sh
index d3a2144..f9bb2d2 100644
--- a/liblist.sh
+++ b/liblist.sh
@@ -75,7 +75,8 @@ list_push_back () {
 #
 list_insert () {
     test "$#" -ne 3 && return 1
-    i="$2"; [ "$i" != '$' ] &&  i=$((i+1)); echo "$3" | sed "${i}i${1}"
+    i="$2"; [ "$i" != '$' ] &&  i=$((i+1)); echo "$3" | sed "${i}i\\
+${1}"
 }
 
 ##
diff --git a/liblist_unsafe.sh b/liblist_unsafe.sh
index 4ae9951..2da93d5 100644
--- a/liblist_unsafe.sh
+++ b/liblist_unsafe.sh
@@ -79,7 +79,8 @@ list_push_back () {
 #
 list_insert () {
     test "$#" -ne 3 && return 1; i="$3"; [ "$i" != '$' ] &&  i=$((i+1))
-    eval "$1=\"\$(echo \"\$$1\" | sed \"${i}i${2}\")\""
+    eval "$1=\"\$(echo \"\$$1\" | sed \"${i}i\\
+${2}\")\""
 }
 
 ##

This solves the immediate problem, at least- the i command is POSIX specified to be the way that we're currently strictly accepting it, and gsed seems to be OK with it. The test suite has some other issues that leave me unable to fully test libshlist and I don't use mons, so I've not submitted a PR for this.

kevans91 avatar Aug 15 '20 02:08 kevans91