diff --git a/Linker_QuickAction.sh b/Linker_workflow.sh similarity index 96% rename from Linker_QuickAction.sh rename to Linker_workflow.sh index 8f4012b..91286ad 100755 --- a/Linker_QuickAction.sh +++ b/Linker_workflow.sh @@ -1,7 +1,7 @@ #!/bin/zsh # shellcheck shell=bash -# Linker Finder QuickAction (workflow) +# Linker Finder workflow (QuickAction or Service) # version 1.0.1 export LANG=en_US.UTF-8 diff --git a/README b/README index 058ec4d..be96865 100644 --- a/README +++ b/README @@ -1,8 +1,7 @@ Linker is a macOS shell script and Finder QuickAction to create relative or absolute symbolic links, hard links, Finder aliases, Bookmark files, file clones or legacy file copies Latest release: https://github.com/JayBrown/Linker/releases/latest -Successfully tested on: macOS 10.15.7 (Catalina) -Not working on: OS X 10.9.5 (Mavericks) +Successfully tested on: macOS 10.15.7 (Catalina) & macOS 10.13.6 (High Sierra) * install linker shell script into your $PATH @@ -19,7 +18,9 @@ Not working on: OS X 10.9.5 (Mavericks) * execute the following, if the script doesn't run: chmod +x ./linker * Mojave & later: install QuickAction workflow with Automator Installer -* on older systems the QuickAction format is either not supported or might not work properly as a Service workflow, and you need to create your own Service workflow in Automator +* High Sierra & earlier: install the Service workflow with Automator Installer + +* Mojave 10.14.3 and earlier (optional): install the Swift 5 Runtime Support for Command Line Tools: https://support.apple.com/kb/DL1998?locale=en_US In Finder you can just use the QuickAction from the contextual menu (or the Service on older systems). diff --git a/linker b/linker index eeaf121..ce68e30 100755 --- a/linker +++ b/linker @@ -1,7 +1,7 @@ #!/bin/zsh # shellcheck shell=bash -# Linker v0.4 +# Linker v0.4.1 export LANG=en_US.UTF-8 export SYSTEM_VERSION_COMPAT=0 @@ -11,21 +11,41 @@ uiprocess="Linker" procid="local.lcars.Linker" # check system version +swiftlib="/usr/lib/swift/libswiftCore.dylib" sysvers=$(sw_vers -productVersion) doublealias=false +noalisma=false noapfs=false vmaj=$(echo "$sysvers" | awk -F"." '{print $1}') if [[ $vmaj -lt 11 ]] ; then vmin=$(echo "$sysvers" | awk -F"." '{print $2}') - if [[ $vmin -lt 13 ]] ; then # no APFS support - noapfs=true - if [[ $vmin -eq 12 ]] ; then - vfix=$(echo "$sysvers" | awk -F"." '{print $3}') - if [[ $vfix -lt 6 ]] ; then # potentially buggy support for new Alias format: needs to be separated from Bookmark file - doublealias=true + vfix=$(echo "$sysvers" | awk -F"." '{print $3}') + if [[ $vmin -eq 14 ]] ; then + if [[ $vfix -le 3 ]] ; then # Mojave 10.14.3 and earlier: needs Swift libraries for alisma + if ! [[ -f "$swiftlib" ]] ; then + noalisma=true fi - elif [[ $vmin -lt 12 ]] ; then # old Alias format: needs to be separated from Bookmark file - doublealias=true + fi + elif [[ $vmin -eq 13 ]] ; then # High Sierra: needs Swift libraries for alisma + if ! [[ -f "$swiftlib" ]] ; then + noalisma=true + fi + elif [[ $vmin -le 12 ]] ; then # Sierra and earlier + noapfs=true # no APFS support on Sierra and earlier + if [[ $vmin -ge 11 ]] ; then # Swift libraries needed for: El Capitan & Sierra + if ! [[ -f "$swiftlib" ]] ; then + noalisma=true + else # Swift libraries are present + if [[ $vmin -eq 12 ]] ; then + if [[ $vfix -lt 6 ]] ; then # potentially buggy support for new Alias format: needs to be separated from Bookmark file + doublealias=true + fi + elif [[ $vmin -eq 11 ]] ; then # old Alias format: needs to be separated from Bookmark file + doublealias=true + fi + fi + else # Yosemite and earlier: no Swift library & alisma support + noalisma=true fi fi fi @@ -184,10 +204,14 @@ elif [[ $1 == "-s" ]] ; then cli=true shift elif [[ $1 == "-b" ]] ; then - if $doublealias ; then - bookmark=true - else + if $noalisma ; then finderalias=true + else + if $doublealias ; then + bookmark=true + else + finderalias=true + fi fi cli=true shift @@ -3486,26 +3510,32 @@ fi # export additional path & check for availability of alisma export PATH=$PATH:"$bindir" -xalisma=true -if ! command -v alisma &>/dev/null ; then - chmod +x "$bindir/alisma" 2>/dev/null +if $noalisma ; then + xalisma=false +else + xalisma=true if ! command -v alisma &>/dev/null ; then - xalisma=false + chmod +x "$bindir/alisma" 2>/dev/null + if ! command -v alisma &>/dev/null ; then + xalisma=false + else + if ! alisma -h | head -1 | grep "^alisma v[1-9] usage:$" &>/dev/null ; then + xalisma=false + fi + fi else if ! alisma -h | head -1 | grep "^alisma v[1-9] usage:$" &>/dev/null ; then xalisma=false fi fi -else - if ! alisma -h | head -1 | grep "^alisma v[1-9] usage:$" &>/dev/null ; then - xalisma=false - fi fi if $cli ; then # standard alias files can always be created via Finder - if $bookmark && ! $xalisma ; then - _sysbeep & - _notify "⚠️ Bookmark files unsupported!" "alisma CLI is missing!" - exit + if $bookmark ; then + if $noalisma || ! $xalisma ; then + _sysbeep & + _notify "⚠️ Bookmark files unsupported!" "alisma CLI is missing!" + exit + fi fi fi