Skip to content

syntax: make BinaryNextLine also apply to binary test and arithmetic expressions #813

@ContinuousCaffeniation

Description

@ContinuousCaffeniation

When using -bn option, only the first of the two examples below is correct. In the second case below, the binary operators are not formatted to be at the beginning of the line. The second example even gets re-formatted, so that the operators, once corrected manually, appear at the end of line again.

#!/bin/bash
# ok, pipes in front of line
if [[ -z "${foo}" ]] \
    || [[ -z "${bar}" ]] \
    || [[ -z "${baz}" ]]; then
    echo "Hello world"
fi

# nok, pipes at the end of line
if [[ -z "${foo}" ||
    -z "${bar}" ||
    -z "${baz}" ]]; then
    echo "Hello world"
fi

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions