Skip to content

Commit 3171f79

Browse files
committed
qb: fix silent drop of last HAVE_* option when config.params.sh lacks trailing newline
config.params.sh did not end with a newline on its last line (the most recent entries were 'HAVE_MFI=auto ...' before commit ebf6708 added HAVE_AVF=auto as the new last line). qb.params.sh reads the file with the idiom while read -r VAR _; do ... done < 'qb/config.params.sh' Under POSIX semantics, 'read' returns non-zero at EOF when the final line has no terminating newline; the line is still stored in VAR but the 'while' condition is already false, so the loop body is not executed. The practical consequence: whichever HAVE_* option lives on the last line of config.params.sh is silently dropped from OPTS and CONFIG_OPTS. This broke the new HAVE_AVF option: the detection logic in config.libs.sh correctly set HAVE_AVF=yes on macOS 13 after the -framework AVFoundation check succeeded, but because 'AVF' was never added to CONFIG_OPTS, create_config_make and create_config_header never iterated over it, and neither config.mk nor config.h received any HAVE_AVF entry. Makefile.common's 'ifeq ($(HAVE_AVF), 1)' then evaluated to false, the AVFoundation camera and recording driver object files were never compiled or linked, and the drivers were invisible in Settings -> Drivers at runtime. Two-part fix: 1. Harden the read loop with '|| [ -n "$VAR" ]'. This is the canonical POSIX workaround for newline-less files: if 'read' returns non-zero but VAR is non-empty, we have a partial last line and should still process it. Prevents this class of bug from recurring regardless of how config.params.sh is edited. 2. Add a trailing newline to config.params.sh itself. Both fixes are independently sufficient; having both means downstream forks that pull just one commit still get the correct behaviour. This also retroactively un-drops whichever option was the last line in config.params.sh at earlier points in history - anyone building against an older tree with a trailing-newline-less params file would have had silent feature drops for the final option. The only trigger was editing the file without a text editor that enforces a terminal newline (vim writes one by default, nano does not unless configured, echo >> appends a fresh line; direct printf %s '...' writes or some IDEs do not).
1 parent b327848 commit 3171f79

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

qb/config.params.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,4 +217,4 @@ HAVE_BUILTINSMBCLIENT=no # Use builtin libsmb2
217217
HAVE_COCOA=auto # Cocoa support (Darwin/Apple)
218218
HAVE_RETROARCH_PLAYLIST_MANAGER=auto # iOS/tvOS + macOS 10.11+ playlist helper (see qb/config.libs.sh)
219219
HAVE_MFI=auto # GameController.framework joypad support (Apple)
220-
HAVE_AVF=auto # AVFoundation camera + recording drivers (Apple, macOS 10.7+ / iOS)
220+
HAVE_AVF=auto # AVFoundation camera + recording drivers (Apple, macOS 10.7+ / iOS)

qb/qb.params.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,16 @@ parse_input() # Parse stuff :V
9292
CONFIG_OPTS=''
9393
config_opts='./configure'
9494

95-
while read -r VAR _; do
95+
while read -r VAR _ || [ -n "$VAR" ]; do
9696
# Skip blank lines and comment-only lines. Only HAVE_* or
9797
# bare-name=VALUE assignments are meaningful here; anything
9898
# else (like "# comment") would produce a broken eval such
9999
# as 'USER_#=auto'.
100+
#
101+
# The `|| [ -n "$VAR" ]` lets us process the final line even
102+
# when config.params.sh has no trailing newline; otherwise
103+
# `read` returns non-zero at EOF and the loop body is skipped,
104+
# silently dropping whichever option happens to be last.
100105
case "$VAR" in
101106
''|'#'*) continue ;;
102107
esac

0 commit comments

Comments
 (0)