diff --git a/build.sh b/build.sh index 5c2a7e80..a6a410bf 100755 --- a/build.sh +++ b/build.sh @@ -1,23 +1,23 @@ #!/bin/sh ARCHITECTURE=x64 -if [ "$(uname -m)" == "arm64" ]; then +if [ "$(uname -m)" = "arm64" ]; then ARCHITECTURE=arm64 -elif [ -z "$1" ]; then +elif [ -n "$1" ]; then ARCHITECTURE=$1 fi TARGET=linux-$ARCHITECTURE -if [ "$(uname)" == "Darwin" ]; then +if [ "$(uname)" = "Darwin" ]; then TARGET=osx-$ARCHITECTURE -else +elif [ -n "$1" ]; then TARGET=$2-$ARCHITECTURE fi dotnet publish cli/Elk.Cli.csproj -r $TARGET -c Release rm -rf build -if [ "$(uname)" == "Darwin" ]; then +if [ "$(uname)" = "Darwin" ]; then mkdir -p build/$TARGET cp cli/bin/Release/*/$TARGET/publish/Elk.Cli build/$TARGET/elk cp -r cli/bin/Release/*/$TARGET/publish/Resources/* build/$TARGET diff --git a/cli/Elk.Cli.csproj b/cli/Elk.Cli.csproj index 7f1df29e..aea71b0a 100644 --- a/cli/Elk.Cli.csproj +++ b/cli/Elk.Cli.csproj @@ -19,7 +19,7 @@ It's set to ../lib/elk, since this would mean ./usr/lib/elk if the executable is in ./usr/bin. This makes it work in local folder structures. --> - + diff --git a/src/FileUtils.cs b/src/FileUtils.cs index 0871c86e..120ba520 100644 --- a/src/FileUtils.cs +++ b/src/FileUtils.cs @@ -18,16 +18,19 @@ public static class FileUtils { public static bool FileIsExecutable(string filePath) { - if (!File.Exists(filePath)) - return false; - if (OperatingSystem.IsWindows()) return false; - var fileMode = File.GetUnixFileMode(filePath); + var fileInfo = new FileInfo(filePath); + if (!fileInfo.Exists) + return false; return ( - fileMode & (UnixFileMode.OtherExecute | UnixFileMode.GroupExecute | UnixFileMode.UserExecute) + fileInfo.UnixFileMode & ( + UnixFileMode.OtherExecute | + UnixFileMode.GroupExecute | + UnixFileMode.UserExecute + ) ) != 0; }