-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use "rm" instead of "unlink" to delete old config file #2504
Conversation
Wow. OpenBSD is missing a mandatory POSIX utility? Do you know why and since when? |
I think I've found the answer: I'll take a closer look at the suggested change (and merge it if possible) when I get back to my dev machine. Thanks for sending the PR! |
Merged. Thanks again! |
I'm no expert and I only looked into the base72 and base73 file sets additionally to the running base74 file sets but none included an Also some manual steps are needed to make it work as the prompt usually prints [ERROR]: gitstatus failed to initialize.
There is no prebuilt gitstatusd for openbsd amd64.
See: https://github.com/romkatv/gitstatus#compiling I will leave this comment here, if someone should encounter the same problems as I did, this is how I finally got this working on my box: First I cloned the gitstatus repo into a fresh directory. I then went to your libgit2 repository and downloaded the latest tar.gz archive into $ git clone --depth=1 https://github.com/romkatv/gitstatus.git
$ cd gitstatus
$ cp ~/Downloads/libgit2-tag-* deps/
$ bash ./build
$ cp usrbin/gitstatusd ~/.zprezto/modules/prompt/external/powerlevel10k/gitstatus/usrbin/ I bet there is an easier way to obtain these results, but I wasn't able to get this thing running... bash is also not in base, needs to be installed first Sorry for the late reply, you answered yourself a few times meanwhile, I had a longer night today :) |
Given that you already have zsh, you could use that instead of cd ~/.zprezto/modules/prompt/external/powerlevel10k/gitstatus
rm usrbin/gitstatusd
zsh ./build -w You can also use |
I've found another relevant issue: romkatv/gitstatus#282. I think it's better than what I've linked before. The person filing that issue told me that /bin/sh -c 'printf "%s\n" "${KSH_VERSION-unset}"' If it says "unset", can you try to figure out what |
It says unset, right. The manual of sh(1) shows:
I've also looked at the sources but cannot find files similar to sh.c or kind of. Finally the Makefile of ksh makes me think they are "linked", at least this looks like it to me. The script you mentioned above (lines 1-329) do return 0 with $ /bin/sh -c 'printf "%s\n" "${KSH_VERSION-unset}"'
unset
$ /bin/ksh -c 'printf "%s\n" "${KSH_VERSION-unset}"'
@(#)PD KSH v5.2.14 99/07/13.2 The smaller script from above
prints Hope that helps |
When you run
Thanks. This confirms that both If #!/bin/sh
set -ue
build="$(command cat <<\END
blah
...
blah
END
)" For a conformant
Awwww. The "disguise" apparently consists of unsetting |
I just sank under the floor. Of course I know the shebang in scripts. I sometimes tend to ignore the obvious :D
Okay I deleted almost everything out, the resulting file is #!/bin/sh
set -ue
build="$(command cat <<\END
case "$resp" in
hello*0*);;
*)
>&2 echo 'error: invalid gitstatusd response for a non-repo'
exit 1
;;
esac
END
)"
It still fails with only #!/bin/sh
set -ue
build="$(command cat <<\END
case "$resp" in
*)
>&2 echo 'error: invalid gitstatusd response for a non-repo'
exit 1
;;
esac
END
)" as well as with #!/bin/sh
set -ue
build="$(command cat <<\END
case "$resp" in
hello*0*);;
esac
END
)" both error messages are This particular/other error message appears when I reduce the blocks with the unknown variables until the script looks like this: #!/bin/sh
set -ue
build="$(command cat <<\END
outdir="$(command pwd)"
narg() { echo $#; }
appname=gitstatusd
libgit2_tmp="$outdir"/deps/"$appname".libgit2.tmp
cleanup()
trap cleanup INT QUIT TERM ILL PIPE
cpus="$(command getconf _NPROCESSORS_ONLN 2>/dev/null)" ||
cpus="$(command sysctl -n hw.ncpu 2>/dev/null)" ||
cpus=8
libgit2_cmake_flags=
libgit2_cflags="$ $cflags -O3 -DNDEBUG"
for cmd in cat cmake git ld ln mkdir rm strip tar "$gitstatus_make"; do
if ! command -v "$cmd" >/dev/null 2>&1; then
if [ -n "$gitstatus_install_tools" ]; then
>&2 echo "[internal error] $cmd not found"
exit 1
else
>&2 echo "[error] command not found: $cmd"
exit 1
fi
fi
done
. "$outdir"/build.info
if [ -z "${libgit2_version:-}" ]; then
>&2 echo "[internal error] libgit2_version not set"
exit 1
fi
if [ -z "${libgit2_sha256:-}" ]; then
>&2 echo "[internal error] libgit2_sha256 not set"
exit 1
fi
libgit2_tarball="$outdir"/deps/libgit2-"$libgit2_version".tar.gz
if [ ! -e "$libgit2_tarball" ]; then
if [ -n "$gitstatus_download_deps" ]; then
if ! command -v wget >/dev/null 2>&1; then
if [ -n "$gitstatus_install_tools" ]; then
>&2 echo "[internal error] wget not found"
exit 1
else
>&2 echo "[error] command not found: wget"
exit 1
fi
fi
libgit2_url=https://github.com/romkatv/libgit2/archive/"$libgit2_version".tar.gz
if ! >"$libgit2_tmp" command wget --no-config -qO- -- "$libgit2_url" &&
! >"$libgit2_tmp" command wget -qO- -- "$libgit2_url"; then
set -x
>&2 command which wget
>&2 command ls -lAd -- "$(command which wget)"
>&2 command ls -lAd -- "$outdir"
>&2 command ls -lA -- "$outdir"
>&2 command ls -lAd -- "$outdir"/deps
>&2 command ls -lA -- "$outdir"/deps
set +x
exit 1
fi
command mv -f -- "$libgit2_tmp" "$libgit2_tarball"
else
>&2 echo "[error] file not found: deps/libgit2-"$libgit2_version".tar.gz"
exit 1
fi
fi
libgit2_actual_sha256=
if command -v shasum >/dev/null 2>/dev/null; then
libgit2_actual_sha256="$(command shasum -b -a 256 -- "$libgit2_tarball")"
libgit2_actual_sha256="${libgit2_actual_sha256%% *}"
elif command -v sha256sum >/dev/null 2>/dev/null; then
libgit2_actual_sha256="$(command sha256sum -b -- "$libgit2_tarball")"
libgit2_actual_sha256="${libgit2_actual_sha256%% *}"
elif command -v sha256 >/dev/null 2>/dev/null; then
libgit2_actual_sha256="$(command sha256 -- "$libgit2_tarball" </dev/null)"
# Ignore sha256 output if it's from hashalot. It's incompatible.
if [ ${#libgit2_actual_sha256} -lt 64 ]; then
libgit2_actual_sha256=
else
libgit2_actual_sha256="${libgit2_actual_sha256##* }"
fi
fi
if [ -z "$libgit2_actual_sha256" ]; then
>&2 echo "[error] command not found: shasum or sha256sum"
exit 1
fi
if [ "$libgit2_actual_sha256" != "$libgit2_sha256" ]; then
>&2 echo "[error] sha256 mismatch"
>&2 echo ""
>&2 echo " file : deps/libgit2-$libgit2_version.tar.gz"
>&2 echo " expected: $libgit2_sha256"
>&2 echo " actual : $libgit2_actual_sha256"
exit 1
fi
CFLAGS="$libgit2_cflags" command cmake \
-DCMAKE_BUILD_TYPE=None \
-DZERO_NSEC=ON \
-DTHREADSAFE=ON \
-DUSE_BUNDLED_ZLIB=ON \
-DREGEX_BACKEND=builtin \
-DUSE_HTTP_PARSER=builtin \
-DUSE_SSH=OFF \
-DUSE_HTTPS=OFF \
-DBUILD_CLAR=OFF \
-DUSE_GSSAPI=OFF \
-DUSE_NTLMCLIENT=OFF \
-DBUILD_SHARED_LIBS=OFF \
$libgit2_cmake_flags \
..
command make -j "$cpus" VERBOSE=1
app="$outdir"/usrbin/"$appname"
command strip "$app".tmp
resp="$(printf 'hello\037\036' | "$app".tmp)"
case "$resp" in
hello*0*);;
*)
>&2 echo 'error: invalid gitstatusd response for a non-repo'
exit 1
;;
esac
command mv -f -- "$app".tmp "$app"
cleanup
command cat >&2 <<-END
-------------------------------------------------
SUCCESS: created usrbin/$appname
END
END
)" when I remove the |
Very nice job! Let's keep going. If you don't know how to proceed, try these: Is
|
Okay all these snippets on their own produce following output: $ for i in build1 build2 build3 build4 build5 ; do ./$i; done
./build1: here document `END' unclosed
case "$resp" in
hello*0*);;
esac
./build3: here document `END' unclosed
./build4: here document `END' unclosed
./build5: here document `END' unclosed So, is this it? With (build2) -- Is process substitution really necessary? #!/bin/sh
# set -ue
command cat <<\END
case "$resp" in
hello*0*);;
esac
END the script returns 0 and outputs
|
So, what is the smallest script you've identified that exhibits the error? |
I guess it is this one #!/bin/sh
build="$(: <<\END
case x in
*);;
esac
END
)" |
That looks great! One last attempt at simplification and it's done. Checking if the variable is really necessary. #!/bin/sh
: "$(: <<\END
case x in
*);;
esac
END
)" |
that also prints the error |
That would be it. Could you report a bug against OpenBSD? Give them this script and describe what happens when you interpret it with |
What would I expect to happen? This is really a bit too complex for my understanding, I do some basic scripting now and then, but these simplifications are something I never really needed. Now what I think to understand: the text enclosed by "" gets expanded from the shell, which is basically the case switch, which does nothing per default. I don't get the part with : "$(: <<\END but what exactly should the line above do? |
The expected behavior of this script is succeeding without doing anything.
|
this actually let me run the
p10k configure
script on OpenBSD which aborts withgenerate_config:250: command not found: unlink
otherwise.tested on PopOS/Ubuntu but
rm
should also be available on any linux distribution?