Skip to content

Undoes comment terminating multi-line lists or commands to avoid unnecessary diff modification #1290

@guillemj

Description

@guillemj

Hi!

To avoid unnecessary diff modifications, reduce potential accidents, and help with sortability in some cases, I've been using the following pattern on multi-line lists in commands:

#!/bin/sh

cmd_list \
  aa \
  bb \
  cc \
  # EOL

cmd_a \
  | cmd_b \
  | cmd_c \
  | cmd_d \
  # EOC

other

But running for example shfmt -i=2 -bn, disarms this pattern into:

#!/bin/sh

cmd_list \
  aa \
  bb \
  cc
# EOL

cmd_a \
  | cmd_b \
  | cmd_c \
  | cmd_d
# EOC

other

This pattern makes it so that adding, modifying or removing lines changes the minimal amount as possible (except if you need to insert something before cmd_a).

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