Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure improvements #4316

Merged
merged 2 commits into from
May 29, 2021
Merged

Conversation

kmk3
Copy link
Collaborator

@kmk3 kmk3 commented May 28, 2021

$ git log --reverse --pretty='%s%n%n%b%n-----%n' master..HEAD

configure.ac: run autoupdate to fix autoconf warning

This fixes the following warning:

$ autoconf
configure.ac:306: warning: AC_OUTPUT should be used without arguments.
configure.ac:306: You should run autoupdate.

Environment:

$ grep '^NAME' /etc/os-release
NAME="Artix Linux"
$ pacman -Q autoconf
autoconf 2.71-1

Though keep AC_PREREQ at 2.68 (released on 2010-09-23[1]), as version
2.71 (which autoupdate automatically bumps to) is rather recent
(released on 2021-01-28[2]) and the changes do not appear to require a
version bump, as on AC_INIT it only adds some quotes, and the rest of
the changes are consistent with the autoconf 2.68 manual. From Section
18.4, Obsolete Macros[3]:

— Macro: AC_OUTPUT ([file]..., [extra-cmds], [init-cmds])

The use of AC_OUTPUT with arguments is deprecated.  This obsoleted
interface is equivalent to:

          AC_CONFIG_FILES(file...)
          AC_CONFIG_COMMANDS([default],
                             extra-cmds, init-cmds)
          AC_OUTPUT

See AC_CONFIG_FILES, AC_CONFIG_COMMANDS, and AC_OUTPUT.

Note: The usage of the above format has been present since the inception
of configure.ac, on commit 1379851 ("Baseline firejail 0.9.28").

Misc: This is a continuation of #4293.

[1] https://lists.gnu.org/archive/html/info-gnu/2010-09/msg00013.html
[2] https://lists.gnu.org/archive/html/autoconf/2021-01/msg00126.html
[3] https://www.gnu.org/software/autoconf/manual/autoconf-2.68/html_node/Obsolete-Macros.html#index-AC_005fOUTPUT-2058


configure*: use cat instead of many echoes

For simplicity and increased portability.


kmk3 added 2 commits May 28, 2021 18:02
This fixes the following warning:

    $ autoconf
    configure.ac:306: warning: AC_OUTPUT should be used without arguments.
    configure.ac:306: You should run autoupdate.

Environment:

    $ grep '^NAME' /etc/os-release
    NAME="Artix Linux"
    $ pacman -Q autoconf
    autoconf 2.71-1

Though keep `AC_PREREQ` at 2.68 (released on 2010-09-23[1]), as version
2.71 (which autoupdate automatically bumps to) is rather recent
(released on 2021-01-28[2]) and the changes do not appear to require a
version bump, as on `AC_INIT` it only adds some quotes, and the rest of
the changes are consistent with the autoconf 2.68 manual.  From Section
18.4, Obsolete Macros[3]:

> — Macro: AC_OUTPUT ([file]..., [extra-cmds], [init-cmds])
>
>     The use of AC_OUTPUT with arguments is deprecated.  This obsoleted
>     interface is equivalent to:
>
>               AC_CONFIG_FILES(file...)
>               AC_CONFIG_COMMANDS([default],
>                                  extra-cmds, init-cmds)
>               AC_OUTPUT
>
>     See AC_CONFIG_FILES, AC_CONFIG_COMMANDS, and AC_OUTPUT.

Note: The usage of the above format has been present since the inception
of configure.ac, on commit 1379851 ("Baseline firejail 0.9.28").

Misc: This is a continuation of netblue30#4293.

[1] https://lists.gnu.org/archive/html/info-gnu/2010-09/msg00013.html
[2] https://lists.gnu.org/archive/html/autoconf/2021-01/msg00126.html
[3] https://www.gnu.org/software/autoconf/manual/autoconf-2.68/html_node/Obsolete-Macros.html#index-AC_005fOUTPUT-2058
For simplicity and increased portability.
configure Show resolved Hide resolved
Copy link
Collaborator

@rusty-snake rusty-snake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

echo " Always enforce filters: $HAVE_FORCE_NONEWPRIVS"
echo
if test "$HAVE_LTS" = -DHAVE_LTS; then
cat <<\EOF
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDK what the backslash does on a HERE-document, but what about using - and indented body?

if test "$HAVE_LTS" = -DHAVE_LTS; then
	cat <<-EOF

	
	*********************************************************
	*    Warning: Long-term support (LTS) was enabled!      *
	*    Most compile-time options have bean rewritten!     *
	*********************************************************
	
	
	EOF
fi

@kmk3
Copy link
Collaborator Author

kmk3 commented May 28, 2021

@reinerh reviewed 1 hour ago:

did you mean to include the backslash here?

Yes, I use it "defensively" when there is no expansion needed, to ensure that
it's not accidentally done.

Example:

$ cat <<\EOF
Hello from $SHELL
EOF
Hello from $SHELL
$ cat <<EOF
Hello from $SHELL
EOF
Hello from /bin/bash

I'd say it's similar to using single quotes instead of double quotes for
variables.

Interestingly, the POSIX spec only mentions "quoting"[1]:

If any part of word is quoted, the delimiter shall be formed by performing
quote removal on word, and the here-document lines shall not be expanded.
Otherwise, the delimiter shall be the word itself.

But apparently the backslash also counts as quoting (besides single and double
quotes)[2]:

You only need a minimal change; single-quote the here-document delimiter
after <<.

cat <<'EOF' >> brightup.sh

or equivalently backslash-escape it:

cat <<\EOF >>brightup.sh

I use this form because from what I remember reading a long time ago, this is
either the most portable way to avoid expansion in here-documents or just the
more "traditional" style (compared to single/double quotes).

I just looked at configure and that indeed appears to be the case, as that's
what autoconf does:

$ git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
$ grep -F 'cat <<' configure
  cat <<_ACEOF
  cat <<\_ACEOF
  cat <<\_ACEOF
  cat <<\_ACEOF
cat <<_ASUNAME
$

@rusty-snake 1 hour ago:

IDK what the backslash does on a HERE-document

See above.

but what about using - and indented body?

if test "$HAVE_LTS" = -DHAVE_LTS; then
	cat <<-EOF

	
	*********************************************************
	*    Warning: Long-term support (LTS) was enabled!      *
	*    Most compile-time options have bean rewritten!     *
	*********************************************************
	
	
	EOF
fi

Avoiding all indentation that is not intended to be printed appears to be the
most common form in POSIX shell scripts IME, especially in the usage
function. For example:

usage() {
	cat <<EOF
Usage: $(basename "$0") [-a] [-f] FILE
Do foo with FILE.

OPTIONS
  -a  Include all
  -f  Force
EOF
}

I'm not really sure if this is also done because of portability, but I could see
two other reasons:

  1. Avoid excessive indentation when cat is nested multiple levels deep

To keep the code readable/within a reasonable line length, etc.

  1. Ensure that the output is exactly the same as written

For example, to avoid dealing with potential indentation issues between shells
(e.g.: does it trim only tabs or also spaces?), as one might have multiple
(printable) indentation levels inside the here-document.

[1] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07_04
[2] https://stackoverflow.com/a/22698106/10095231

@netblue30
Copy link
Owner

Let's grab it, looks fine!

@netblue30 netblue30 merged commit 6c1b75f into netblue30:master May 29, 2021
@kmk3 kmk3 deleted the configure-improvements branch May 29, 2021 18:19
kmk3 added a commit to kmk3/firejail that referenced this pull request Nov 24, 2021
For increased consistency and readability.

This restores the spaces removed on commit bf81cd6 ("configure.ac: run
autoupdate to fix autoconf warning") / PR netblue30#4316.

Command used to check for the lack of whitespace:

    grep ',[^ ]' configure.ac
@kmk3 kmk3 mentioned this pull request Nov 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants