On Sat, 14 Aug 2021 15:54:02 +0200 "Roberto A. Foglietta" <[email protected]> wrote:
> Il giorno sab 14 ago 2021 alle ore 15:37 Emmanuel Deloget <[email protected]> > ha scritto: > > > Hello, > > > > On Sat, Aug 14, 2021 at 12:19 PM Roberto A. Foglietta > > <[email protected]> wrote: > > > > > > Hi all, > > > > > > how long could be a shell function name? > > > > > > In my last patch, I used 256 characters because: "On Linux: The maximum > > length for a file name is 255 bytes". So, I have extended the concept to a > > function name but it is not the same. > > > > > > Thank you, > > > > According to the discussion in [1], both bash and NETBSD sh can be > > used with identifiers that are longer than 1000 characters. Bash seems > > to not have any limit on identifier names. The POSIX sh standard > > itself does not define anything related to the length of any > > identifier (be it a variable name or a function name). > > > > (I would totally accept shorter identifiers ; mine rarely goes larger > > than 30-40 bytes, and these are the longest ; yet it's not difficult > > to image a processor that could create longer identifier names). > > > > I checked what happens when the function name is longer than the size of > the buffer: nothing bad. > The buffer is going to be filled but I did not see any buffer overrun. Thus > it is safe, AFAIK. > > Reporting only the first 256 characters of the function name seems also to > me enough. Hi, what happens if two functions have a 257 char long name that differ only in the last char? Why don't make the names as long as needed with a dynamically allocated buffer? Ciao, Tito > roberto@vm-ubuntu18:~/tinycore-editor/busybox$ gcc -o test6 test6.c > roberto@vm-ubuntu18:~/tinycore-editor/busybox$ ./test6 > output: 'FUNCNAME=ciao' > > Ciao, > -R _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
