summaryrefslogtreecommitdiff
path: root/www/blog/2020-01-13/index.html
blob: 7100ff6c76e8a580f12c26ab420bfdbdb129371d (plain)
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
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="generator"
        content="HTML Tidy for HTML5 for Linux version 5.6.0">
  <title>senders.io - Blog</title>
  <link rel='stylesheet'
        type='text/css'
        href='/index.css'>
  <meta name="viewport"
        content="width=device-width, initial-scale=1">
</head>
<body>
  <div id='header'>
    <a class='title'
         href='/'>senders.io</a>
    <nav>
      <a href="/resume">Resume</a> <a href="/blog">Blog</a> <a href=
      "https://github.com/s3nd3r5">Github</a>
    </nav>
  </div>
  <div id='body'>
    <article>
      <h2>remember/recall - what could&#39;ve been a command line tool</h2>
      <p>During a meeting at work when I realized I often forget useful
      commands. So I had the bright idea to create a command line tool that
      would basically append a file with the command you wanted to remember
      that you could search over later if you wanted to recall a certain
      command. I figured I could it could just be a simple bash script that
      recalls your bash-history and appends it to a file, all things that are
      incredibly easy to do... or so I thought.</p>
      <h3>Look before you leap</h3>
      <p>This article is a reminder to myself to test the core functionality
      first, before decorating your program/script with all those bells and
      whistles. While I did learn a lot in the process it is always a good to
      check the basics first.</p>
      <h3>What went right</h3>
      <p>I actually ended up learning a lot during the development of the
      (never finished) tool. I had never used <code>getopts</code> inside a
      script before, which turned out to be extremely intuitive. That was all
      that went right...</p>
      <h3>What went wrong</h3>
      <p>Literally, everything else that could&#39;ve went wrong did. The
      &quot;project&quot; was a single bash script roughly 160 lines long
      before I found out it wouldn&#39;t work. It was a series of flags that
      enabled actions that called functions, some of which ended the script
      either successfully or not. It wasn&#39;t necessarily a mess to read (I
      tried to make it that every function ended up in an exit so I knew if I
      entered I would need to assume it terminated) but it was hard to follow
      when writing. I tried to allow it so you could default an action to make
      the CLI intuitive which lead to a messy set of if/elses and switch
      cases.</p>
      <h4>You can&#39;t access un-committed bash history</h4>
      <p>History command in a bash shell commits the history at the end of the
      session. This makes sense once you know this, there are a lot of reasons
      saving the commands to file after every execution is probably not the
      best idea. However, it can be enabled with a flag when you enable a shell
      session. But I didn&#39;t want to build a tool that required me to
      remember I had to add something to my bash_profile before it would work.
      I wanted something I could just copy onto a new machine and have access
      to its functionality.</p>
      <h3>Lesson learned</h3>
      <p>While developing a tool to help me remember things, I learned
      something I cannot forget: Test the core, simplest functionality first.
      Before you do anything validate what you&#39;re trying to do will work.
      Because after building all of these fancy bells and whistles, if it
      can&#39;t do the basics, there is no point.</p>
    </article>
    <div id='footer'>
      <i>Updated and finally posted February 16, 2020</i>
    </div>
    <div id='copyright'>
      © 2023 senders dot io - <a rel="license external noopener noreferrer"
           target="_blank"
           href="https://creativecommons.org/licenses/by/4.0/">CC BY-SA 4.0</a>
           unless otherwise noted.
    </div>
  </div>
</body>
</html>