[FFmpeg-devel] [PATCH V4 2/2] configure: replace 'pr' with printf since busybox does not support pr
avihpit at yahoo.com
Wed Apr 24 15:15:32 EEST 2019
> how about add the keyword local which makes the variables not global.
No. It's not portable and not standard, and will break with a lot of shells
which ffmpeg currently supports.
Different shells have different ways to limit a variable scope to the current
function, some don't have a way at all, and some limits some variables
automatically (like the value variable in a `for` command).
There are only two standard ways for limited-scope values:
- A function's positional parameters are local to each instance (including
each instance in a recursion).
- A subshell prevents all changes to variables outside of it, with two issues:
1. Code can't actually modify any variables outside of its subshell...
2. It can be very expensive where/if (a big if) performance matters.
There are ways to implement locality of variables while staying portable. In
ffmpeg's configure `pushvar` and `popvar` were used for such functionality
(they still exist in configure but currently unused). Their usage was
replaced with a method based on storing prior values in positional parameter
(in a recursive function) and restoring them later.
There are also more generic solutions, with varying degrees of complexity and
performance. I wrote such solution myself, and some day I might send a patch
to ffmpeg which incorporates it.
Till then, there's no generic way to set local variables in `configure`
except the two methods mentioned above, or using a unique enough name.
More information about the ffmpeg-devel