6/23/2023 0 Comments Clickcharts no newline after enter![]() (there is no newline after output on the last line due to using echo -n). Steps to reproduce: open Terminal (i assume fish is. (there is no newline after output on the last line due to using echo -n). No newline after typing command and pressing enter Issue 4100 fish-shell/fish-shell GitHub Fish version: fish, version 2.6.0 OS: Haiku x8664 hrev51178 echo TERM : xterm (Haiku standard Terminal application) Tested without third-party mods, with clean settings. Further output to that line will then overwrite what was previously outputted there.Ĭonverting the script to a Unix text file will solve your issue: $ bash -x script.shĭos2unix: converting file script.sh to Unix format. Unix text files don't have this, and when a Unix system is outputting such a character, it causes the cursor position to move to the very start of the line. That said, it is surprising that the world that has banner, figlet, boxes, and cowsay didn't create and make widespread a simple utility that could emit various styles of horizontal rule in all these years.Your script is a DOS text file, meaning it contains a carriage return character (often written \r) at the end of each and every line. (The usual caveats apply: Some old real terminals respond to non-ECMA-48 control sequences, and tput rp is a better approach than printf in the general case, even though the non-ECMA-48 case is quite unlikely in practice you must check the correct terminal type, that matches your terminal, not just wrongly assume "Oh, it's xterm." and your terminfo/termcap database must be up-to-date.) You can check the termcap/terminfo database for the repeat_char/ rep capability to determine whether a terminal type supports REP. This works with pretty much all shells, even the Debian Almquist shell. So as long as your real video terminal or terminal emulator understands something that was standardized in the 1970s, and you aren't using a paper terminal (which is vanishingly unlikely), printing 20 times can be done with no shell-specific syntax, no command pipelines, no substitutions or stream editing, and just printf: printf 19 ![]() XTerm was well ahead of most and has understood it since 1996, but libVTE and KDE Konsole didn't catch up until 20. Whereas the likes of the DEC VT5xx series in the 1990s understood REP, it is only within the last decade that it has become commonplace on terminal emulators. It has taken terminal emulators some time to catch up with real terminals. This repeats the previous graphic character printed (amongst other things, which I won't go into here as we only care about graphic characters). One can take advantage of the facts that (a) video terminals are not "dumb", and never really have been and (b) nowadays, in the third decade of the 21st century, most video terminals and even their emulators, largely agree on understanding ECMA-48, rather than a control sequence system of their own.ĮCMA-48, since its earliest days in the 1970s, has defined a control sequence REP, which is CSI, a parameter, and b as the final character. There is nothing wrong in doing so, but there is an alternative approach. Other answers have taken the tack of using the extensions to standard shell syntax that are available in specific shells such as the Korn, Z, and Bourne Again shells. Print -rC1 - is like printf '%s\n' or print -rl - to print one element per line except in the case where no arguments are passed to it (like when lines=()) in which case it prints nothing instead of an empty line). Short text the m flag causes zsh to take into account the display width of each character (like for those double-width characters above (which your browser may not render with exactly double-width, but your terminal should)). If the end-goal is to display a list of strings padded to the width of the screen, you'd do: $ lines=(short 'longer text' 'even longer') ( printf '%s\n' "$string" can be written print -r - "$string" or echo -E - "$string" in zsh, though if $string doesn't contain backslashes and doesn't start with -, that can be simplified to print "$string"/ echo "$string"). ![]() You could also use print or echo here which do add a \n by default. ![]() You could also use the right padding one here). With zsh: printf '%s\n' the l left-padding parameter expansion flag.
0 Comments
Leave a Reply. |