Why is this script treating the files with the same names as the same files?
1
vote
1
answer
258
views
#!/usr/bin/bash
install_wm() {
echo "$(dirname "$0")"
cd "$(dirname "$0")" && pwd
mkdir -p /root/.config && cd /root/.config &&
git clone https://git.suckless.org/dwm && cd dwm && pwd &&
diff "$(dirname "$0")/config.def.h" /root/.config/dwm
cp -f "$(dirname "$0")/config.def.h" /root/.config/dwm &&
}
install_wm
When I run this script as root
I get
.
/home/jim/CS/SoftwareDevelopment/MySoftware/Bash/ubuntu-server-LTS
Cloning into 'dwm'...
remote: Enumerating objects: 6504, done.
remote: Counting objects: 100% (6504/6504), done.
remote: Compressing objects: 100% (3216/3216), done.
remote: Total 6504 (delta 3733), reused 5933 (delta 3287), pack-reused 0
Receiving objects: 100% (6504/6504), 6.18 MiB | 8.86 MiB/s, done.
Resolving deltas: 100% (3733/3733), done.
/root/.config/dwm
cp: './config.def.h' and '/root/.config/dwm/config.def.h' are the same file
I run this script as root
.
$(dirname "$0")/config.def.h
is my config file that has different content, and is located in the same directory as the script,
than the one in the cloned repo. Why do I get from cp
'./config.def.h' and '/root/.config/dwm/config.def.h' are the same file
if the files only have the same names and not the content?
Also when I run diff
on the two files manually, outside of the script, I get the output that shows the difference between them:
22,23c22,23
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
>
30,34c30,31
{ "Gimp", NULL, NULL, 0, 1, -1 },
> { "Firefox", NULL, NULL, 1 /* commands */
66,71c61
static const char *termcmd[] = { "st", NULL };
whereas I don't get any output when diff
is run from within my script. What is happening here?
Asked by John Smith
(827 rep)
Oct 12, 2023, 08:18 AM
Last activity: Oct 12, 2023, 08:34 AM
Last activity: Oct 12, 2023, 08:34 AM