diff --git a/README.md b/README.md index 3263a39..d1583d1 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,104 @@ +## TESTS SIGNAUX WITH HERE-DOCS : +**bash** +1. dans l'exemple ci-dessous j'ecris ^D a l'emplacement où je le tape, mais en vrai il n'apparait pas dans bash +et j'ai mis a gauche le compte des lignes de heredocs cumulés depuis le debut du process +```text + [zsh]$ bash + [bash]$ echo << EOF +1 > ^D bash: warning: here-document at line 1 delimited by end-of-file (wanted `EOF') + + [bash]$ echo << EOF +2 > ^D bash: warning: here-document at line 2 delimited by end-of-file (wanted `EOF') + + [bash]$ echo << EOF +3 > ^D bash: warning: here-document at line 3 delimited by end-of-file (wanted `EOF') + + [bash]$ echo << EOF +4 > +5 > ^D bash: warning: here-document at line 4 delimited by end-of-file (wanted `EOF') + + [bash]$ echo << EOF +6 > ^D bash: warning: here-document at line 6 delimited by end-of-file (wanted `EOF') + + [bash]$ echo << EOF +7 > ^D bash: warning: here-document at line 7 delimited by end-of-file (wanted `EOF') + + [bash]$ echo << EOF +8 > +9 > +10 > ^D bash: warning: here-document at line 8 delimited by end-of-file (wanted `EOF') + + [bash]$ echo << EOF +11 > ^D bash: warning: here-document at line 11 delimited by end-of-file (wanted `EOF') + + [bash]$ echo << EOF +12 > +13 > +14 > +15 > ^D bash: warning: here-document at line 12 delimited by end-of-file (wanted `EOF') + + [bash]$ echo << EOF +16 > +17 > +18 > +19 > ^D bash: warning: here-document at line 16 delimited by end-of-file (wanted `EOF') + + [bash]$ echo << EOF +20 > ^D bash: warning: here-document at line 20 delimited by end-of-file (wanted `EOF') + + [bash]$ echo << EOF +21 > EOF + + [bash]$ echo << EOF +22 > ^D bash: warning: here-document at line 23 delimited by end-of-file (wanted `EOF') + + [bash]$ +``` +le texte de warning ne decrit pas la ligne du heredoc au niveau de laquelle ^D a ete pressé +il decrit la premiere ligne de chaque heredoc (donc peut importe qu'on ai fait un heredoc de 1 ligne ou de 25 lignes, il donne le numero de la premiere), plus le nombre total de lignes de tous les heredocs depuis le debut du process (j'ai l'impression) +et quand il rencontre un DELIMITER ca compte pour deux lignes (DELIMITER + '\n' je pense) + +2. Ctrl-C quite le mode heredoc a n'importe quel moment, Ctrl-D quite le mode heredoc avec un message, uniquement si le curseur est vide + +3. heredoc avec un echo interrompu par un Ctrl-D saute un ligne avant le nouveau prompt, mais pas heredoc avec un cat : +```text +[bash]$ echo << EOF +> ^C +[bash]$ echo << EOF +> ^D bash: warning: here-document at line 2 delimited by end-of-file (wanted `EOF') + +[bash]$ cat << EOF +> ^C +[bash]$ cat << EOF +> ^D bash: warning: here-document at line 4 delimited by end-of-file (wanted `EOF') +[bash]$ +``` + +4. avec une redirection dans un fichier, le heredoc ecrit dans le fichier a la reception du DELIMITER ou bien d'un Ctrl-D, mais pas d'un Ctrl-C : + +avec Ctrl-D : +```text +[bash]$ cat << EOF > file.txt +> hello +> test +> ^D bash: warning: here-document at line 1 delimited by end-of-file (wanted `EOF') +[bash]$ cat file.txt +hello +test +``` +avec Ctrl-C +```text +[bash]$ cat << EOF > file.txt +> bonjour +> heredoc a l'appareil +> ^C +[bash]$ cat file.txt +hello +test +``` + + + ## understanding some things : - [how to send EOF to stdin of a shell process](https://unix.stackexchange.com/questions/493578/how-to-send-d-eot-character-to-stdin-of-a-shell-process) - [get root access 1](https://vitux.com/how-to-become-root-user-in-ubuntu-command-line-using-su-and-sudo/)