Skip to content

Clarify/Document the interaction of -f with -ln/-p #1161

@sdavids

Description

@sdavids
$ mkdir -p /tmp/test && cd "$_"
$ printf '#!/usr/bin/env sh\necho one\n' >one.sh
$ printf '#!/usr/bin/env bash\necho two\n' >two


$ shfmt -f .
one.sh
two


$ shfmt -f -ln=bash .
one.sh
two


$ shfmt -f -ln=posix .
one.sh
two


$ shfmt -f -p .
one.sh
two

One could argue that -f in combination with -ln/-p should filter and only show the matching scripts:

$ shfmt -f -ln=bash .
two

$ shfmt -f -ln=posix .
one.sh

$ shfmt -f -p .
one.sh

This would be useful if one wants to copy only scripts of a specific dialect.

Let's say one has a host/docker image without bash and one just wants to copy the POSIX-conformant scripts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions