[Openvpn-devel,v4] dev-tools/reformat-shell.sh: Make our shell code more consistent

Message ID 20260820091512.4550-1-gert@greenie.muc.de
State New
Headers
Series [Openvpn-devel,v4] dev-tools/reformat-shell.sh: Make our shell code more consistent |

Commit Message

Gert Doering Aug. 20, 2026, 9:15 a.m. UTC
  From: Frank Lichtenheld <frank@lichtenheld.com>

Our shell code is currently not very consistent about
formatting. So provide a tool to achieve that consistency.
Especially in our test code we have several important shell
scripts that we actively develop.

Change-Id: I80a94dde26631e5a665029f495b2104cfecb1915
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Razvan Cojocaru <razvanc@mailbox.org>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1792
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1792
This mail reflects revision 4 of this Change.

Acked-by according to Gerrit (reflected above):
Razvan Cojocaru <razvanc@mailbox.org>
  

Comments

Gert Doering Aug. 20, 2026, 10:15 a.m. UTC | #1
This doesn't add or change any code in the repo yet, but it provides the
tooling to keep our shell scripts in matching style later on - and having
it in the repo means "everyone can run it".  As we usually do :-)

Nothing tested yet, but we discussed the desired output, and what comes
in the next patch "all makes sense".

Your patch has been applied to the master branch.

commit 5663fd71f4358e404031d57f9ec1acbb0b78358a
Author: Frank Lichtenheld
Date:   Thu Aug 20 11:15:07 2026 +0200

     dev-tools/reformat-shell.sh: Make our shell code more consistent

     Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
     Acked-by: Razvan Cojocaru <razvanc@mailbox.org>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1792
     Message-Id: <20260820091512.4550-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg38546.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering
  

Patch

diff --git a/dev-tools/reformat-shell.sh b/dev-tools/reformat-shell.sh
new file mode 100755
index 0000000..dbbdaa9
--- /dev/null
+++ b/dev-tools/reformat-shell.sh
@@ -0,0 +1,14 @@ 
+#!/bin/sh
+#
+# Apply consistent formatting to our shell code.
+# Uses shfmt: https://github.com/mvdan/sh
+
+set -u
+
+FORMAT_ARGS="--indent=4 --func-next-line --case-indent"
+FORMAT_CMD="shfmt --list --write"
+
+# hardcoded to --posix due to .in filename and invalid shebang
+$FORMAT_CMD --posix $FORMAT_ARGS ./tests/t_client.sh.in
+# handle *.sh files recursively
+$FORMAT_CMD $FORMAT_ARGS ./tests ./dev-tools