On Mon, 18 Dec 2017, Riccardo (Jack) Lucchetti wrote:
On Mon, 18 Dec 2017, Sven Schreiber wrote:
> Am 18.12.2017 um 09:17 schrieb Riccardo (Jack) Lucchetti:
>> On Sun, 17 Dec 2017, Allin Cottrell wrote:
>>
>>> The second priority is then to future-proof function packages by ensuring
>>> that they use the currently recommended form -- and in that context, I
>>> agree, some "shell magic" would be helpful.
>>
>> A proper implementation would have to use our internal tokenizer, but for
>> a rough check this bash fragment may come in useful (it only catches
"if"s
>> a
>
> Ahem, could it be you're talking about the == thing here? The current (or
> future) problem was the 'sprintf' command.
Ah, ok, sorry.
I think the following could be a base for automatic sanitizing of sprintf
<bash>
# converts sprintf commands into sprintf functions
sed $1 -e 's/sprintf \([A-Za-z_0-9]*\) \(.*\)/string \1 = sprintf(\2)/'
</bash>
better (preserves indentation and adds a comment)
<sprintf.sed>
s/^\([ \t]*\)sprintf \([A-Za-z_0-9]*\) \(.*\)/\1# was: sprintf \2 \3\n\1string \2 =
sprintf(\3)\n/
</sprintf.sed>
<bash>
sed $1 -f sprintf.sed
</bash>
so for example
<hansl>
sprintf ii "%d", i-2
</hansl>
becomes
<hansl>
# was: sprintf ii "%d", i-2
string ii = sprintf("%d", i-2)
</nansl>
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------