--- 
canonical: 'https://mwop.net/blog/2026-02-18-cli-options-with-globs.html'
title: 'Globbing files to pass to CLI command options'
author: "[Matthew Weier O'Phinney](https://mwop.net)"
created: '2026-02-18T13:56:00-06:00'
updated: '2026-02-18T13:56:00-06:00'
tags:
  - bash
  - cli
  - fish
  - makefile

---
I've been using Helm recently as part of a new product offering, and as a way to deploy my various websites. Helm allows providing _values_ to the templates in a Helm chart via one or more _values_ files, which are provided via the option `-f`. It's often useful to break these into several files, so you can do things like cover common values, and then environment- or namespace-specific values.

However, the `-f` option only accepts a single value, and doesn't recognize globs.





## The printf solution

The solution is to pass the glob to `printf`, with the format `'-f %s '`. This will print out an option per file.

When in a terminal, this can be done using `printf` within a subshell. Now _how_ you do that depends on the shell, because the `-f` in our format string can be interpreted as an option/flag to `printf` itself depending on the shell.

For bash, we can do this:

```bash
helm upgrade -n qa . $(printf -- '-f % ' *.values.yaml)
```

This is because `printf` in bash will emit an error for any unknown option/flag it encounters; the `--` tells the command when the end of all options/flags have been reached, so that it treats the remainder as arguments.

For fish, we don't need the `--`, as the `printf` implementation in fish doesn't accept arguments anyways:

```bash
helm upgrade -n qa . $(printf '-f % ' *.values.yaml)
```

## Makefile

Of course, subshells in a `Makefile` require a little change as well. In a `Makefile`, I write the above as:

```
helm upgrade -n qa . $(shell printf -- '-f %' *.values.yaml)
```

(And since I also declare `SHELL=/bin/bash` at the top of my `Makefile`, I have to use the `--` trick here.)