Resolve symbolic links when copying bundle resources in Xcode
A solution could be to insert a Run Script Build Phase which performs the copy exactly the way you want, i.e., by dereferencing symbolic links (this is the default behaviour of cp).
why are some cygwin symlinks not visible from a cmd.exe session
The reason why the links are not visible is due to their file Attribute
S = System
are not visible in CMD by DOS/Windows design,
from CMD, sorry in German, we have:
$ cmd
Microsoft Windows [Version 10.0.19041.450]
(c) 2020 Microsoft Corporation. Alle Rechte vorbehalten.
D:\cygwin64\bin>attrib zipinfo
S D:\cygwin64\bin\zipinfo
D:\cygwin64\bin>dir zipinfo
Datenträger in Laufwerk D: ist DATA
Volumeseriennummer: D603-FB6E
Verzeichnis von D:\cygwin64\bin
Datei nicht gefunden
D:\cygwin64\bin>dir /A:S zipinfo
Datenträger in Laufwerk D: ist DATA
Volumeseriennummer: D603-FB6E
Verzeichnis von D:\cygwin64\bin
19.06.2018 22:17 16 zipinfo
1 Datei(en), 16 Bytes
0 Verzeichnis(se), 542.542.495.744 Bytes frei
Git symbolic links in Windows
You can find the symlinks by looking for files that have a mode of 120000
, possibly with this command:
git ls-files -s | awk '/120000/{print $4}'
Once you replace the links, I would recommend marking them as unchanged with git update-index --assume-unchanged
, rather than listing them in .git/info/exclude
.
Git Bash shell fails to create symbolic links
It is possible, albeit extremely awkward, to create a symbolic link in MSysGit.
First, we need to make sure we are on Windows. Here's an example function to check that:
windows() { [[ -n "$WINDIR" ]]; }
Now, we can't do cmd /C
, because MSysGit will fornicate with this argument and turn it into C:
. Also, don't be tempted to use /K
; it only works if you don't have a K:
drive.
So while it will replace this value on program arguments, it won't on heredocs. We can use this to our advantage:
if windows; then
cmd <<< "mklink /D \"${link%/}\" \"${target%/}\"" > /dev/null
else
ln -s "$target" "$link"
fi
Also: note that I included /D
because I'm interested in directory symlinks only; Windows has that distinction. With plenty of effort, you could write a ln() { ... }
function that wraps the Windows API and serves as a complete drop-in solution, but that's... left as an exercise for the reader.
As a thank-you for the accepted answer, here's a more comprehensive function.
# We still need this.
windows() { [[ -n "$WINDIR" ]]; }
# Cross-platform symlink function. With one parameter, it will check
# whether the parameter is a symlink. With two parameters, it will create
# a symlink to a file or directory, with syntax: link $linkname $target
link() {
if [[ -z "$2" ]]; then
# Link-checking mode.
if windows; then
fsutil reparsepoint query "$1" > /dev/null
else
[[ -h "$1" ]]
fi
else
# Link-creation mode.
if windows; then
# Windows needs to be told if it's a directory or not. Infer that.
# Also: note that we convert `/` to `\`. In this case it's necessary.
if [[ -d "$2" ]]; then
cmd <<< "mklink /D \"$1\" \"${2//\//\\}\"" > /dev/null
else
cmd <<< "mklink \"$1\" \"${2//\//\\}\"" > /dev/null
fi
else
# You know what? I think ln's parameters are backwards.
ln -s "$2" "$1"
fi
fi
}
Also note a few things:
- I just wrote this and briefly tested it on Windows 7 and Ubuntu, give it a try first if you're from 2015 and using Windows 9.
- NTFS has reparse points and junction points. I chose reparse points, because it's more of an actual symbolic link and works for files or directories, but junction points would have the benefit of being an usable solution in Windows XP, except it's just for directories.
- Some filesystems, the FAT ones in particular, do not support symbolic links. Modern Windows versions do not support booting from them anymore, but Windows and Linux can mount them.
Bonus function: remove a link.
# Remove a link, cross-platform.
rmlink() {
if windows; then
# Again, Windows needs to be told if it's a file or directory.
if [[ -d "$1" ]]; then
rmdir "$1";
else
rm "$1"
fi
else
rm "$1"
fi
}
Related Topics
How to Save Output of "Watch" to File
Selecting the Right Linux I/O Scheduler for a Host Equipped with Nvme Ssd
Convert Utf8 to Utf16 Using Iconv
How to Send Data to Local Clipboard from a Remote Ssh Session
One Core Exclusively for My Process
What Should Linux/Unix 'Make Install' Consist Of
Shell Script to Get the Process Id on Linux
How to Get Exit Status of a Shell Command Used in Gnu Makefile
How to Detect When Someone Opens the Slave Side of a Pty (Pseudo-Terminal) in Linux
Read a Single Sector from a Disk
How to Cut First Column (Variable Length) of a String in Shell
Using Find - Deleting All Files/Directories (In Linux ) Except Any One
Getting Error on Supervison on Supervisorctl Error (No Such Process)
How to List All Users in a Linux Group
Using Grep to Search for a String That Has a Dot in It
Async Connect and Disconnect with Epoll (Linux)
Does Ldd Also Show Dependencies of Dependencies
How to Convert ".." in Path Names to Absolute Name in a Bash Script