On 2013-11-27 20:19, enoquick wrote:
[...]
> Non sono andato a leggere i sorgenti della bash ma mi stupirei se usasse
> altro
Ho fatto un "grep" di "truncate" sui sorgenti
di bash 4.2 ed ha trovato:
$ find . -type f -name \*.[ch] -print0 | xargs -0 grep truncate
./redir.c: will fail. Make sure that we do not truncate an existing
file.
./bashhist.c: Note that the history file is automatically truncated
to the
./variables.c: d = xd; /* truncate */
./variables.c: numeric, truncate the history file to hold no more than
that many
./variables.c: history_truncate_file (get_string_value
("HISTFILE"), hmax);
./lib/readline/history.h:extern int history_truncate_file PARAMS((const
char *, int));
./lib/readline/histfile.c:history_truncate_file (fname, lines)
./lib/readline/histfile.c: /* Don't try to truncate non-regular files. */
./lib/readline/histfile.c: goto truncate_exit;
./lib/readline/histfile.c: goto truncate_exit;
./lib/readline/histfile.c: goto truncate_exit;
./lib/readline/histfile.c: goto truncate_exit;
./lib/readline/histfile.c: goto truncate_exit;
./lib/readline/histfile.c: number of lines we want to truncate to,
so we don't need to do
./lib/readline/histfile.c: truncate to. */
./lib/readline/histfile.c: ftruncate (file, chars_read - (bp -
buffer));
./lib/readline/histfile.c: truncate_exit:
./lib/readline/histfile.c: if (ftruncate (file, buffer_size+cursize)
== -1)
"ftruncate()" e` usata per la "histfile" in "readline",
ma non in "redir.c".
Riguardo "unlink()":
$ find . -type f -name \*.[ch] -print0 | xargs -0 grep unlink
./subst.h:extern void unlink_fifo_list __P((void));
./subst.h:extern void unlink_fifo __P((int));
./subst.h:extern void unlink_new_fifos __P((char *, int));
./redir.c: unlink (filename);
./redir.c: unlink (filename);
./redir.c: if (unlink (filename) < 0)
./execute_cmd.c: /* don't unlink fifos if we're in a shell function;
wait until the function
./execute_cmd.c: unlink_fifo_list ();
./execute_cmd.c: unlink_fifo_list ();
./execute_cmd.c: unlink_fifo_list ();
./execute_cmd.c: unlink_fifo_list ();
./execute_cmd.c: unlink_fifo_list ();
./execute_cmd.c: unlink_fifo_list ();
./execute_cmd.c: unlink_fifo_list ();
./execute_cmd.c: unlink_fifo_list ();
./sig.c: unlink_fifo_list ();
./sig.c: unlink_fifo_list ();
./sig.c: unlink_fifo_list ();
./shell.c: unlink_fifo_list ();
./shell.c: unlink_fifo_list ();
./subst.c:/* Named pipes must be removed explicitly with `unlink'. This
keeps a list
./subst.c: of FIFOs the shell has open. unlink_fifo_list will walk
the list and
./subst.c: unlink all of them. add_fifo_list adds the name of an open
FIFO to the
./subst.c:unlink_fifo (i)
./subst.c: unlink (fifo_list[i].file);
./subst.c:unlink_fifo_list ()
./subst.c: unlink (fifo_list[i].file);
./subst.c: unlink_fifo_list ();
./subst.c: unlink_fifo (i);
./subst.c: unlink_fifo (i);
./subst.c:unlink_fifo (fd)
./subst.c:unlink_fifo_list ()
./subst.c: unlink_fifo (i);
./subst.c: unlink_fifo_list ();
./subst.c: unlink_fifo (i);
./subst.c: unlink_fifo (i);
./subst.c: unlink_fifo_list ();
./eval.c: unlink_fifo_list ();
./lib/sh/rename.c: if (unlink (to) < 0 && errno != ENOENT)
./lib/sh/rename.c: if (unlink (from) < 0 && errno != ENOENT)
./lib/sh/rename.c: unlink (to);
./lib/readline/util.c: unlink(fnbuf);
./examples/loadables/unlink.c:/* unlink - remove a directory entry */
./examples/loadables/unlink.c:unlink_builtin (list)
./examples/loadables/unlink.c: if (unlink (list->word->word) != 0)
./examples/loadables/unlink.c: builtin_error ("%s: cannot unlink:
%s", list->word->word, strerror (errno));
./examples/loadables/unlink.c:char *unlink_doc[] = {
./examples/loadables/unlink.c:struct builtin unlink_struct = {
./examples/loadables/unlink.c: "unlink", /* builtin name */
./examples/loadables/unlink.c: unlink_builtin, /* function implementing
the builtin */
./examples/loadables/unlink.c: unlink_doc, /* array of long
documentation strings. */
./examples/loadables/unlink.c: "unlink name", /* usage synopsis;
becomes short_doc */
./examples/loadables/ln.c: /* If -f was specified, and the destination
exists, unlink it. */
./examples/loadables/ln.c: if ((flags & LN_UNLINK) && exists && unlink
(dst) != 0)
./examples/loadables/ln.c: builtin_error ("%s: cannot unlink: %s",
dst, strerror (errno));
./examples/loadables/ln.c: "file. The -f option means to unlink any
existing file, permitting",
./builtins/mkbuiltins.c: unlink (to);
./builtins/mkbuiltins.c: unlink (from);
Ci sono tre chiamate in "redir.c".
bye,
--
piergiorgio