# Naming Parameter name similar to a unix command (seen with 'unzip') fails Shell Script Block using the command

**URL:** <https://community.jenkins.io/t/naming-parameter-name-similar-to-a-unix-command-seen-with-unzip-fails-shell-script-block-using-the-command/11822>\
**Category:** Community\
**Tags:** bug\
**Created:** [January 16, 2024, 12:22pm UTC](https://community.jenkins.io/t/naming-parameter-name-similar-to-a-unix-command-seen-with-unzip-fails-shell-script-block-using-the-command/11822 "2024-01-16T12:22:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nikhil-Kan](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/nikhil-kan/32/6751_2.png) [@Nikhil-Kan](https://community.jenkins.io/u/Nikhil-Kan)\
**Post date:** [January 16, 2024, 12:22pm UTC](https://community.jenkins.io/t/naming-parameter-name-similar-to-a-unix-command-seen-with-unzip-fails-shell-script-block-using-the-command/11822/1 "2024-01-16T12:22:12Z")

</div>

Hello Community!

Faced a potential Bug where using a Named Parameter with name shared by a Unix command (I’ve faced it with _unzip_) fails the actual ‘unzip’ command with weird outputs. (Clueless to why the behavior is such).

Since i’m new here, im also unaware on the procedure to Submit a Bug, thus welcoming you to this topic.

This was rather easy to replicate, and occurs each time.  
**Example:**  
Expected error when zip file is not present

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/0/0d6524a22a076f6489b3ca5d37bc2273632bd251.png)

Here the file is present, and the error is that parameter value is being taken as filename (First argument to unzip is interchanged with UNZIP’s parameter value)

**Script:**

```groovy
properties([
    parameters([
        string(defaultValue: 'thisisbreaking', 
                  description: 'Test Paramter', 
                  name: 'UNZIP', trim: true)
    ])
])    
node('agent_name') {
    dir('/tmp/folder') {
        sh 'unzip thisisazipfile.zip'
    }
}

```

**Output:**  
[Pipeline] Start of Pipeline  
[Pipeline] node  
Running on _Node_ in _workspace path_  
[Pipeline] {  
[Pipeline] dir  
Running in /tmp/folder  
[Pipeline] {  
[Pipeline] sh  
ls -la  
total 348  
drwxrwxrwx 2 user user 4096 Jan 16 16:27 .  
drwxrwxrwt 23 root root 344064 Jan 16 16:30 …  
-rw-rw-r-- 1 user user 172 Jan 16 16:10 thisisazipfile.zip  
unzip thisisazipfile.zip  
unzip: cannot find or open thisisbreaking, thisisbreaking.zip or thisisbreaking.ZIP.  
[Pipeline] }  
[Pipeline] // dir  
[Pipeline] }  
[Pipeline] // node  
[Pipeline] End of Pipeline  
ERROR: script returned exit code 9  
Finished: FAILURE

Any help or direction to raise this as a Bug would be welcome 🙂

Temporary fix is to not use ‘UNZIP’ as a parameter name.

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [January 17, 2024, 3:55am UTC](https://community.jenkins.io/t/naming-parameter-name-similar-to-a-unix-command-seen-with-unzip-fails-shell-script-block-using-the-command/11822/2 "2024-01-17T03:55:44Z")

</div>

The Unix `unzip` command reads the environment variable `UNZIP` as command line arguments. See the output of `man unzip` on your computer for more details.

---

<div class="post-metadata">

**Author:** ![Nikhil-Kan](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/nikhil-kan/32/6751_2.png) [@Nikhil-Kan](https://community.jenkins.io/u/Nikhil-Kan)\
**Post date:** [January 17, 2024, 5:57am UTC](https://community.jenkins.io/t/naming-parameter-name-similar-to-a-unix-command-seen-with-unzip-fails-shell-script-block-using-the-command/11822/3 "2024-01-17T05:57:19Z")

</div>

Thanks for the reply @MarkEWaite !

I also had a look at [Pipeline Syntax](https://www.jenkins.io/doc/book/pipeline/syntax/#parameters) and realized all parameters are exported as env variables.

I assume this behavior was introduced recently as we had the same script running in earlier version of Jenkins without this interaction.

To summarize, is it correct to say never name parameters same as any env var and unix keywords in general?

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [January 17, 2024, 7:34pm UTC](https://community.jenkins.io/t/naming-parameter-name-similar-to-a-unix-command-seen-with-unzip-fails-shell-script-block-using-the-command/11822/4 "2024-01-17T19:34:03Z")

</div>

> [@Nikhil-Kan](#):
>
> I assume this behavior was introduced recently as we had the same script running in earlier version of Jenkins without this interaction.

As far as I know, that has been the behavior for Jenkins job parameters since the very early days of Jenkins. It is the behavior for parameterized freestyle jobs and for parameterized matrix jobs and for parameterized Pipeline jobs. Without that behavior, it is very difficult to pass the values of parameters to shell steps, batch steps, and powershell steps.

> [@Nikhil-Kan](#):
>
> To summarize, is it correct to say never name parameters same as any env var and unix keywords in general?

It is good to not name a parameter the same as an existing environment variable. Naming a parameter the same as an existing environment variable (like `PATH`) is generally a bad idea because it will confuse users of the job when the value of the existing environment variable is replaced.

It is rarely a problem to name a parameter the same as an existing Unix command or even to name it as the upper case form of an existing Unix command. The `unzip` command is rather distinct in its technique of accepting command line arguments through an environment variable named `UNZIP`. There may be other Unix commands that use the same technique, but I’m not aware of any.

---

<div class="post-metadata">

**Author:** ![Nikhil-Kan](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/nikhil-kan/32/6751_2.png) [@Nikhil-Kan](https://community.jenkins.io/u/Nikhil-Kan)\
**Post date:** [January 18, 2024, 6:07am UTC](https://community.jenkins.io/t/naming-parameter-name-similar-to-a-unix-command-seen-with-unzip-fails-shell-script-block-using-the-command/11822/5 "2024-01-18T06:07:54Z")

</div>

Got it! Thanks for the clarification!
