<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Ruslan&#39;s Tech Blog</title>
    <link>https://blog.bekenev.net/tags/bash.html</link>
    <description>Software development related stuff</description>
    <language>en-us</language>
    <lastBuildDate>Wed, 31 Jan 2018 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://blog.bekenev.net/tags/bash/feed.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Bash. Variables inside aliases</title>
      <link>https://blog.bekenev.net/2018/01/31/alias-variables.html</link>
      <pubDate>Wed, 31 Jan 2018 00:00:00 +0000</pubDate>
      <guid>https://blog.bekenev.net/2018/01/31/alias-variables.html</guid>
      <description>&lt;p&gt;Hey,&lt;/p&gt;&#xA;&lt;p&gt;Recently I had to use bash alias that contains &lt;code&gt;$(pwd)&lt;/code&gt; inside so I&amp;rsquo;ve defined it like that:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;alias thename&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;something &lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;$(&lt;/span&gt;pwd&lt;span style=&#34;color:#66d9ef&#34;&gt;)&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; --option=value&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br/&gt;&#xA;&lt;p&gt;Of course I know a bit of bash so that&amp;rsquo;s why I use double quotes!&lt;/p&gt;&#xA;&lt;center&gt;&lt;img alt=&#34;how I feel&#34; src=&#34;https://media.giphy.com/media/BrZTIgDc7VmnK/giphy.gif&#34; width=&#34;200px&#34;/&gt;&lt;/center&gt;&#xA;&lt;p&gt;But it turned out to be wrong. Each time when my bash/zsh was opened the alias was defined with &lt;strong&gt;INTERPRETED&lt;/strong&gt; &lt;code&gt;$(pwd)&lt;/code&gt;&#xA;which is the directory where bash was opened (usualy home dir).&lt;/p&gt;&#xA;&lt;p&gt;Actually we have to use single quotes to make sure that &lt;code&gt;$(pwd)&lt;/code&gt; isn&amp;rsquo;t interpreted at the moment of alias definition but it is&#xA;when we call the alias.&lt;/p&gt;&#xA;&lt;h2 id=&#34;summary&#34;&gt;Summary&lt;/h2&gt;&#xA;&lt;br/&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;use single quotes if you want to make sure variable/command is interpreted during the alias call.&lt;/li&gt;&#xA;&lt;li&gt;use double quotes if you only want to interpretate variable/command on the alias definition stage (and only once).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;</description>
    </item>
  </channel>
</rss>
