From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 382 invoked from network); 11 Feb 2022 13:31:00 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 11 Feb 2022 13:31:00 -0000 Received: (qmail 28605 invoked by uid 550); 11 Feb 2022 13:30:57 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 28573 invoked from network); 11 Feb 2022 13:30:56 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=GHkVqXK+ENq02Qq0ayV8dihe1oRAHBZkZNM3ao7YepI=; b=HN1bCa83/V7rn/YmYbC/Y5CdsUUoy58H3j35e69nJ3fjMdkGFJ37xlsxR52XQRTuoE vOjiz/twQBIHzaxC71YmabNnfYSYhhCP/vQQct0SzHuR15q8jfwUV5bkysrIPQ6JT7wf KMHEX8SFZESGRmHV3Q/mwBQDDRJ84mhJb8MOyJK9zRkhgzZn1TNk4U79tzRsSdmObyxt jM0KjVqU1QcXP+EbKmvZ7M3ge71Iag9lFAnV++YVEDm473uc2YHsrkFWjo0/UiFG9mDa 8ntWNChTYwmCdNpj/sl0rwDwL5yQhuRAx77MWLhT4SmP6xcDfvwNwvqZ2NVNtuorVPkV kGNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=GHkVqXK+ENq02Qq0ayV8dihe1oRAHBZkZNM3ao7YepI=; b=uTU+HPgYXfEtj0BtElJW6geUDeVCweP88cUtnrCyH8d1XFxl3140DQb7knZeZvwPiH QYlrisjRYVu5ZMY9/SMKJ4zgGvpiFB+0lM0T2sGJIscep1FLTGS2qkGv2UevaD7G7t76 ez51YqGm+OzSyA8MqzU8Yc/J17rji2OmcYgQi4VP+9NuHTadNNinGl/8pxjv3wQ5NSBH ySK0fyHVshyx9xcyMFIqFzo0EA/wEba7PHLIHaJlVZfwQ8EPEWogXDrKKcIv2wd1Thnc 8lwRtCKM4ltB80e+1R9QgFM5in0dOhb4R4S4dm2Ur0SaLo97kvFrPjNJbIQhAhHyjz46 y6QQ== X-Gm-Message-State: AOAM533yW5PAnqlr0IUB9vhkmTxmDVyVO1K73PNM0yq/BkLhAhMYiwdd eMTlCpEMHj0SRwpdrSaYAwWFsdLssdOXT4TRK5U7rGqIEg== X-Google-Smtp-Source: ABdhPJxlgQT9eMpGX5mxFdl04mV9jkwxqmurCJO9xx/LynRUlI865Q/7lDYuwzprA1sVIPWVAMGc19YTWYjqPDVAY1Y= X-Received: by 2002:a17:90b:4a0a:: with SMTP id kk10mr389259pjb.200.1644586243952; Fri, 11 Feb 2022 05:30:43 -0800 (PST) MIME-Version: 1.0 From: Yuri Kanivetsky Date: Fri, 11 Feb 2022 15:30:32 +0200 Message-ID: To: musl@lists.openwall.com Content-Type: text/plain; charset="UTF-8" Subject: [musl] What determines the TERM variable value? Hi, I was told recently that I can set TERM to any value inside a docker container, which is, sort of, at odds with my understanding. And my understanding is as follows. When a program creates a pseudoterminal (a pty master/slave pair), it sort of becomes a terminal emulator. I guess, it can decide not to process any escape sequences in which case the pair is probably not much different from an ordinary pipe. And basically what sequences it decides to process determines the TERM variable value. I can separate such programs into 2 categories: * Terminal emulators (xterm, urxvt, ...). They receive input, process escape sequences, and draw the result in a window. They can invent their own language (escape sequences), but it's probably best to have some terminal as a base. * The rest (docker, ssh, tmux, screen, ...). They receive input, translate escape sequences to the language of the process up the chain (by using the TERM variable and the terminfo database), and pass the result to stdout (text, optionally with translated escape sequences). So, generally you have a chain of processes connected via pseudoterminals (a pty master/slave pairs). E.g. xterm <-> ssh <-> tmux <-> docker. Also, you can't set TERM to an arbitrary value. Each program that creates a pseudoterminal supports a fixed set of values. E.g. the tmux documentation says: > For tmux to work correctly, this must be set to screen, tmux or a derivative of them. https://man.archlinux.org/man/community/tmux/tmux.1.en Is my understanding correct? Also, I have a pretty vague understanding of what the TERM variable affects. Can you give some examples? Or categorize things in some way? Is it only about escape sequences? Regards, Yuri