-
Notifications
You must be signed in to change notification settings - Fork 0
/
2019-08-02-the-danger-of-fuzzy-matching-over-ones-path.html
162 lines (144 loc) · 6.67 KB
/
2019-08-02-the-danger-of-fuzzy-matching-over-ones-path.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="alternate"
type="application/rss+xml"
href="https://blog.winny.tech/rss.xml"
title="RSS feed for https://blog.winny.tech/"/>
<title>The Danger of fuzzy matching over one's PATH</title>
<link href="static/style.css?v=1.7" rel="stylesheet" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div id="preamble" class="status">
<nav>
<div class="flexcontainer">
<div class="smallitem">
blog.winny.tech
</div>
<div class="bigitem">
<ul class="inline-list">
<li><a href=".">Home</a></li>
<li><a href="archive.html">Archive</a></li>
<li><a href="tags.html">Tags</a></li>
<li><a href="rss.xml">RSS Feed</a></li>
</ul>
</div>
</div>
</nav>
<hr/>
</div>
<div id="content">
<div class="post-date">02 Aug 2019</div><h1 class="post-title"><a href="2019-08-02-the-danger-of-fuzzy-matching-over-ones-path.html">The Danger of fuzzy matching over one's PATH</a></h1>
<p>
Awhile back I noticed my personal <code>mnt/</code> directory, my (empty) personal
<code>tmp/</code> directory, and a few symbolic links disappeared from my home
directory. I only noticed because I use unison<sup><a id="fnr.1" class="footref" href="#fn.1">1</a></sup> to synchronize my
desktop and laptop homedirs. The actual amount of removed directories
and symbolic links were staggering, and it costed me five minutes of
extra effort to search through the unison UI to ignore files I don’t
want to synchronize. Repeat this a few times a day, with the problem
occurring at seemingly random intervals, and you’ve wasted minutes out
of every day, which adds up to hours every month.
</p>
<p>
For months I had not figured out what the problem was. By chance I had
noticed while using my application launcher, I had accidentally not
ran <code>links -g</code> <sup><a id="fnr.2" class="footref" href="#fn.2">2</a></sup> but instead had ran <code>cleanlinks</code>. I wonder to myself
what was I running by accident, as I had done this before, but had not
thought anything of it, assuming it was a program that would print
usage or perform a no-operation by default.
</p>
<p>
I was wrong.
</p>
<p>
Turns out <code>cleanlinks</code> searches the current working directory for <b>empty</b>
directories and <b>broken</b> symbolic links. Both are useful. For example I
keep empty directories in <code>~/mnt/</code> to mount <code>sshfs</code> stuff, and I prefer to
use <code>~/tmp/</code> as a work directory because no system scripts will touch
it.<sup><a id="fnr.3" class="footref" href="#fn.3">3</a></sup> I had a few <b>broken</b> symbolic links scattered about, from
weird git repositories working trees to some stale user-level systemd
unit links from my archlinux install.
</p>
<p>
Making things more interesting, if you run <code>cleanlinks --help</code>, or with
any flags, it operates as usual. So it’s a mistake to also do
<code>cleanlinks /some/directory/i/want/to/clean</code>. As a part of imake,<sup><a id="fnr.4" class="footref" href="#fn.4">4</a></sup>
the old X11 ecosystem build tools, <code>cleanlinks</code> will be installed on
many systems and it’s not safe to run it lest you enjoy random stuff
being messed about with in your current directory.
</p>
<p>
How did I manage to run <code>cleanlinks</code> so many times? I did not have links
installed on the affected machine. And even after I did install it, I
forgot to remove <code>cleanlinks</code> from my rofi runcache. So it had a higher
precedence to match than <code>links</code> in certain cases. Hence I ran it a few
times on accident even after installing links.
</p>
<p>
Therefore, I strongly recommend one doesn’t fuzzy match over their
<code>PATH</code>. Who knows what other nasty tools ship on your system that will
lay waste your productivity, or worse, damage your personal files.
</p>
<p>
Regardless, I have yet to heed my own warning. Maybe I should just use
<code>.desktop</code> files, but then again, maybe there exists a
<code>cleanlinks.desktop</code>… Ideally, I’ll create a directory of symlinks to
programs I want to launch from rofi. Someday :)
</p>
<div id="outline-container-org97543e9" class="outline-2">
<h2 id="org97543e9">About Unison</h2>
<div class="outline-text-2" id="text-org97543e9">
<p>
I should mention unison is a superb tool for synchronizing your
data. It shows the user a list of changes to each directory being
synchronized, waits for the user to decide which way each file should
be synchronized:
</p>
<ol class="org-ol">
<li>Send file from host A to B</li>
<li>Send file from host B to A</li>
<li>Ignore the file this time</li>
<li>Ignore the file permanently</li>
<li>Merge the files</li>
</ol>
<p>
Because unison doesn’t try to be fancy or automatic, it is easy to
understand what is happening.
</p>
</div>
</div>
<div id="footnotes">
<h2 class="footnotes">Footnotes: </h2>
<div id="text-footnotes">
<div class="footdef"><sup><a id="fn.1" class="footnum" href="#fnr.1">1</a></sup> <div class="footpara"><p class="footpara">
<a href="https://www.cis.upenn.edu/~bcpierce/unison/">Unison homepage</a>
</p></div></div>
<div class="footdef"><sup><a id="fn.2" class="footnum" href="#fnr.2">2</a></sup> <div class="footpara"><p class="footpara">
Links 2 is the best web 1.0 browser. It even shows images and
different text sizes. Screenshots on <a href="http://links.twibright.com/features.php">this page</a>.
</p></div></div>
<div class="footdef"><sup><a id="fn.3" class="footnum" href="#fnr.3">3</a></sup> <div class="footpara"><p class="footpara">
<code>/var/tmp/</code> could also work, but this way I know nobody is gunna
mess with my files and I won’t accidentally mess up permissions on
sensitive data.
</p></div></div>
<div class="footdef"><sup><a id="fn.4" class="footnum" href="#fnr.4">4</a></sup> <div class="footpara"><p class="footpara">
<a href="https://gitlab.freedesktop.org/xorg/util/imake">imake on freedesktop’s GitLab</a>. See also what packages depend on
imake <a href="https://www.archlinux.org/packages/extra/x86_64/imake/">in Arch Linux</a>. I use Gentoo across my laptop and workstation, so
it’s necessary to have imake installed.
</p></div></div>
</div>
</div><div class="taglist"><a href="tags.html">Tags</a>: <a href="tag-computing.html">computing</a> <a href="tag-rant.html">rant</a> </div></div>
<div id="postamble" class="status">
<hr/>
<ul class="inline-list interpunct">
<li>Powered by <a href="https://github.com/bastibe/org-static-blog">org-static-blog</a></li>
<li>Like what I do? <a href="https://www.buymeacoffee.com/winny">Buy me a Coffee</a></li>
</ul>
<p>© Winston Weinert (winny) — <a href="https://creativecommons.org/licenses/by-sa/4.0/legalcode">CC-BY-SA-4.0</a></p>
</div>
</body>
</html>