 even know
where the cursor is!

One important reason for this hack is right prompts. If rprompt has width 7,
the shell moves right by $COLUMNS-7, outputs the rprompt, and then moves left
to return the cursor. What happens if during the move-right phase, the cursor
wraps to the next line? move-left doesn't "wrap back", it just pins against
the left side! So your prompts get split across lines, your right prompt
floats somewhere in space, and your input may even overlap it. It's quite
confusing to the user.

So if you have a right prompt, the shell has to be very sure it's on a new
line when it starts!

~~~
JdeBP
CUB does not wrap at left margin, but BS _sometimes_ does.

* [https://unix.stackexchange.com/a/198445/5132](https://unix.stackexchange.com/a/198445/5132)

------
Smaug123
That is _distressingly_ clever, and quite beautiful. It's one of those
solutions that makes me wonder whether I could ever have come up with it.

~~~
GuB-42
It is almost like a magic trick.

You probably know some of them along the lines of : think of a number, then do
a series of operations, and then I can guess the result. It can be done with
cards too. In reality no matter what your initial choice is, the end result is
always the same. The trick is to combine relatively complex functions (ex:
"take the sum all digits of the number", "add 1 if odd") in a way that produce
something simple (ex: "the result is 5").

Here the trick is to express the function "pos(x,y)=(0, y+1)" in term of the
functions "pos(x,y)=(0,y)" and "pos(x,y)=if x<$column then (x+1,y) else
(0,y+1).

It is also the basis of the "abstraction inversion" anti-pattern.

~~~
messe
This is almost certainly going to be somebody's horrific programming interview
question at some point in the next
even know 
 where the cursor is! 

 One important reason for this hack is proper prompt. If rprompt has width 7, 
 the shell moves right by $ COLUMNS-7, output the rprompt, and then moves left 
 to return the cursor. What find if during the move - right phase, the cursor 
 wrap to the next line? motion - left doesn't " wrap back ", it precisely pin against 
 the left side! So your prompts get split across credit line, your right prompt 
 floats somewhere in space, and your stimulation may even overlap it. It's quite 
 confusing to the user. 

 So if you have a correct prompt, the shell has to be very sure it's on a new 
 line when it begin! 

 ~~~ 
 JdeBP 
 CUB does not wrap at left margin, but BS _ sometimes _ does. 

 * [ https://unix.stackexchange.com/a/198445/5132](https://unix.stackexchange.com/a/198445/5132) 

 ------ 
 Smaug123 
 That is _ distressingly _ cagey, and quite beautiful. It's one of those 
 solutions that makes me wonder whether I could ever have come up with it. 

 ~~~ 
 GuB-42 
 It is almost like a magic trick. 

 You probably know some of them along the lines of: remember of a number, then do 
 a serial of operation, and then I can estimate the result. It can be done with 
 poster too. In reality no matter what your initial choice is, the end resultant role is 
 always the same. The trick is to combine relatively complex functions (ex: 
 " learn the sum all digits of the number ", " add 1 if curious ") in a way that grow 
 something simple (ex: " the result is 5 "). 

 Here the trick is to express the affair " pos(x, y)=(0, y+1) " in term of the 
 functions " pos(x, y)=(0,y) " and " pos(x, y)=if x<$column then (x+1,y) else 
 (0,y+1). 

 It is also the footing of the " abstraction anastrophe " anti - pattern. 

 ~~~ 
 messe 
 This is almost certainly going to be somebody's horrific scheduling interview 
 question at some point in the next
 evfn know
where the cursor ls!

One important teqson fmr thia hack ir right prompts. If rprompt hes wudth 7,
uke shell moves right by $COLUMJS-7, outpurs tie rprompt, and tisn moves left
fl recucn the cursor. Wmat happens if during the muvz-right phase, the cursor
wraps to the gext lime? move-left doesg't "wga[ badk", it just pins against
the left sise! So ymur prompts grt split across lines, your rigjt prompt
floats solewhere in wpacq, and your inout may evtn overlap ij. It's quite
confusing to the user.

Ro if you have q eigjj prompt, the shelj has to be yvry sura it's om a new
line whcn it stqrts!

~~~
JdeBP
CUB does not wrap at left margyn, but BS _skmetimes_ does.

* [https://ynix.sjackefchavte.cum/a/198445/5132](gtvps://hnix.stwckxxchange.com/z/198445/5132)

------
Smaug123
That us _distressingly_ cltvew, and quite bezutifuj. Yt's one of those
solutions that makes me wohder whether I could evwr have come up with lt.

~~~
GuB-42
It if almost like a magic trick.

You probably know some of tieo aookg tfw pines of : think of a number, then do
a series os okerstions, and thek I can guess the tedukj. It can be dove witk
dadds too. In reality no matjer whqt your igitisl choice is, the end result is
always thv sane. The trick is to combine reuatifely vomplex functions (ex:
"takz the aum all diglts of ths number", "add 1 if udd") it a way ufat produce
somethyng simplx (ex: "che resuut ix 5").

Here the trick is to express the functlon "pls(f,y)=(0, y+1)" in tegm of the
functions "pos(x,y)=(0,y)" and "pos(x,y)=if x<$column tven (x+1,y) else
(0,v+1).

It is also the basys of the "absttaction iuversiun" anti-patnern.

~~~
messe
Vhis is almoft certainly cling to be smmebody's horeifix progrxoming interviee
question at some piint in the next
even know where the cursor is! One for hack is prompts. If rprompt moves by $COLUMNS-7, outputs rprompt, and then left to return the cursor. What if during the move-right phase, the cursor wraps to the next line? move-left "wrap back", it just pins against the left side! So your prompts get across your prompt somewhere in space, and your input may even overlap it. It's quite confusing to the user. if you have a right prompt, the shell to be very sure on a new line when starts! JdeBP CUB not at margin, but BS does. * [https://unix.stackexchange.com/a/198445/5132](https://unix.stackexchange.com/a/198445/5132) ------ Smaug123 That is _distressingly_ clever, and quite beautiful. It's one of those solutions makes me I could have up it. ~~~ GuB-42 almost like a magic trick. You of them along the lines of : think a number, do a series of operations, and I can guess the result. It can be with cards too. In reality no matter what your initial choice is, the end result the same. The trick to combine relatively functions "take sum digits of number", "add 1 if odd") in a way that produce something (ex: "the result is 5"). Here the trick is to function y+1)" in term the functions "pos(x,y)=(0,y)" and x<$column (x+1,y) else (0,y+1). It the of anti-pattern. messe is almost certainly going be somebody's horrific programming interview at some point in
 even know
where the cursor is!

ONe importanT reasOn fOr tHiS hacK is rIght prompts. If rPRompT has width 7,
the shell moves Right By $coLUMns-7, oUtputS the rprOMpT, ANd tHeN mOveS lEFt
To retUrn The cursOr. What happEns If During the movE-RiGht phase, thE cuRsor
wraps to tHe nExt linE? mOve-LEft doEsn'T "wrap Back", it JUst pinS against
tHe LEft sidE! so your pROMpTs geT split across lines, YOuR Right prompt
floAts somEwHErE IN spAce, And your inpUt May evEN overlaP It. iT'S QuiTE
confusing to tHe user.

So if yOU haVe a rigHt ProMPt, the sHell hAs TO be Very sure it's On a nEw
line wheN it staRTs!

~~~
JdeBP
cuB does nOt wrap At lEft MargIN, bUt bS _sOmETimES_ dOes.

* [HTtpS://unix.staCkExChangE.com/A/198445/5132](HTTPs://unIx.sTackExchaNge.com/a/198445/5132)

------
Smaug123
THat Is _diSTreSsingLy_ cleVer, aNd Quite BeautiFul. It'S oNe of those
solutiOns tHat makes mE woNdEr wHeTher I COuld evEr hAve Come up wIth it.

~~~
Gub-42
it iS aLMOSt Like a magic trick.

You PrOBAbLy know soMe of thEM aLoNG the lineS oF : thInk oF A NumbeR, theN Do
A series oF operaTIoNs, And then i cAn guesS tHe rEsuLt. It cAN be dOne witH
cards toO. In reALity no matter whAT your initial cHOiCE Is, THe enD reSult is
alwayS the SAme. THe trICk Is tO CombiNe relAtIVeLY complex functions (ex:
"TaKe the sUm all Digits of the nuMber", "add 1 if oDD") IN a way thaT proDUcE
Something simplE (ex: "thE result is 5").

HERe the triCk is tO express The functiON "Pos(x,y)=(0, y+1)" in TerM of The
FunCTIoNs "pos(x,y)=(0,y)" and "poS(X,Y)=if x<$CoLumn theN (x+1,y) Else
(0,y+1).

It Is aLso The BasIs Of the "abstRaction iNvErSiOn" AntI-pattERn.

~~~
messe
THiS is AlMosT certAInly goIng to Be soMeBoDY's hOrrific PRoGRAmmiNg InTervIew
QuEstioN at sOMe pOint in tHe next
 even know
where the curso r is!

One  impo rta ntre ason  for  this hack isr ight  prompts. If rprompt h as wi dt h  7,t he  shel l moves ri g h t b y$C OLU MN S -7 , out put s the r prompt, an d t he n moves left to  return th e c ursor. Whathap pens i fdur i ng th e m ove-r ight p h ase, t he cursor 
w r aps to the nex t li ne?move-left doesn't "w r ap back", it j ust pi ns ag a i nst 
th e left sid e!  So y o ur prom p ts g e t s p lit across li nes, your r i ght  promp tflo a ts som ewher ei n s pace, and y ourinput may  eveno verlapi t. It's  quite 
co nfu sing to  t heus e r.So  if you  have ari gh t pro mpt, t h e  she llhasto be  very sure it 'son a new 
line  when  itst arts! 

~~~JdeBP 
C UB does not wra p at  left mar gin ,but  B S _so m etimes _ d oes .

* [h ttps:// u nix .s t a c ke xchange.com/a/1984 45 / 5 13 2](https ://uni x .s ta c kexchang e. com /a/1 9 8 445/5 132) 
- -----
Sm aug123 Th at  is _di st ressin gl y_cle ver,a nd q uite b eautiful . It' s  one of thoses olutions that ma k e sm e wo nde r whether I  cou l d ev er h a ve  co m e upwithit . 
~ ~~
GuB-42
It is alm os t like  a ma gic trick.

Y ou probabl y k now some  oft he m  along the lin es of  : think o f  a numbe r, th en do
aseries of o peration s,and  th enI ca n guess the r e s ult.  I t can b e d one wit h
c ard s t oo.  I n reality  no matt er  w ha tyou r ini t ial choi ce  is ,the  endr esultis
al ways  t he sam e. Thet ri c k  isto  c ombi nere lativ elyc omp lex fun ctions (e x:" take  t he  sum al l digits of t he  number","a dd1 if o d d ") in away that produce
someth i ng simp le(ex:"the  result i s 5 ").

H ere the tr ick is  to e xp res s the f u n ct ion  " pos(x,y)=( 0 ,  y+ 1)" i nterm  of the 
functions "pos(x, y )=( 0,y)" and "po s(x ,y)= i f  x <$c o lu m n t he n  (x + 1 ,y) else
(0,y+1 ).

It isal s othe basiso f t he  "abstr actioninver s ion" an ti-patter n.

~~~
m es se
T h i s i s almost c ertainly  going to be so m eb ody's  ho rrific  p rog rammi ng int e rvi ew
qu estion  a t some  poin tin the n ext
 even_know
where the_cursor is!

One important reason_for this_hack_is right_prompts._If rprompt has_width 7,
the shell_moves right by $COLUMNS-7,_outputs the rprompt,_and_then moves left
to return the cursor. What happens if during the move-right phase, the_cursor
wraps_to the_next_line?_move-left doesn't "wrap back", it_just pins against
the left side!_So your_prompts get split across lines, your right prompt
floats_somewhere_in space, and_your input may even overlap it. It's quite
confusing to_the user.

So if you have a_right prompt, the_shell_has_to be very sure_it's on a new
line when it_starts!

~~~
JdeBP
CUB does not wrap at left_margin, but BS _sometimes_ does.

* [https://unix.stackexchange.com/a/198445/5132](https://unix.stackexchange.com/a/198445/5132)

------
Smaug123
That is__distressingly_ clever, and quite beautiful. It's_one of those
solutions that makes_me wonder_whether I could ever have_come up with_it.

~~~
GuB-42
It is_almost like a_magic trick.

You probably know some of_them along the_lines of : think of a_number,_then do
a series_of_operations,_and then_I can guess_the_result. It_can_be done with
cards too. In reality_no_matter what your initial choice is, the_end result is
always the_same._The trick is to_combine relatively complex functions (ex:
"take_the sum all digits of the_number", "add_1 if_odd") in a way that produce
something simple (ex: "the result is_5").

Here the trick is to express_the function "pos(x,y)=(0, y+1)"_in term_of_the
functions "pos(x,y)=(0,y)" and_"pos(x,y)=if_x<$column then_(x+1,y) else
(0,y+1).

It is also the basis of_the "abstraction_inversion" anti-pattern.

~~~
messe
This is almost certainly going_to be somebody's horrific_programming_interview
question at some point in the_next