From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "R. Diez" Newsgroups: gmane.emacs.help Subject: Surprising behaviour of 'append' with strings Date: Sun, 6 Nov 2022 12:05:07 +0100 Message-ID: <6554cc02-2082-3dca-73cc-05fee1c6c4d0@yahoo.de> References: <6554cc02-2082-3dca-73cc-05fee1c6c4d0.ref@yahoo.de> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27060"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Nov 06 12:06:03 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ordTW-0006om-SN for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 06 Nov 2022 12:06:02 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ordT6-0002w9-Qm; Sun, 06 Nov 2022 06:05:36 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ordSw-0002uQ-7P for help-gnu-emacs@gnu.org; Sun, 06 Nov 2022 06:05:26 -0500 Original-Received: from sonic302-20.consmr.mail.ir2.yahoo.com ([87.248.110.83]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ordSn-0003Cf-2I for help-gnu-emacs@gnu.org; Sun, 06 Nov 2022 06:05:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s2048; t=1667732710; bh=ijB00KJ7CsFKz/DLn643p5x1KHQQPm5xhMmxkPyiYbA=; h=Date:From:Subject:To:References:From:Subject:Reply-To; b=Bg/YAxzwIwiRnE/F5RvuoKXVbolzx02h2Q8k8j+sYsC7I27n6pKTOIEbUqoQpa6+7AMu9Y0kD2PS4fPtTGe5ZIIZ3InmBzeSVaPTrEeq0f35Up6Gvio+vCiuQwhkopYkJTsVWRvRRUFWHtbNXxjVf+EBVhn19xtLUqt+C8MMHBg5PQHVaEqisyI5sUp1iDrCYwwsRMu5RLwqHjxLBqqOXN2AvL64VaH9H+DpscOZ9qtigvDITpM7IMgHyZHDaocSCuawv/P4YktIvJTXQzpKs30jgUC9mxQt6y2rw8NSQAN54ZNInsh7OiKpIsDgCCHJ5B5DhQkaq4cmVTOWjZN15A== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1667732710; bh=cRxnofkAgfOEBoDFalP1b8158TqBRqeDyJkV0HEEY9O=; h=X-Sonic-MF:Date:From:Subject:To:From:Subject; b=AdYFOezJ1rjTfoQxd5V2mOA45D1tLIGsP4ZDUPc0OH7m0I5garpY5zg9uYBepMI2qlNgCRaqkFfQD4N1GlnyYnZpwyAnjiKiHWmNvrhnoyrG277J/9+BtKR8pL3M+2kK0b3uwgYhIx4rC9yozzNrnwOr13NytEqS0gH5WasF/cl+Qz/iTAMT9G7QncO6sJiwWYqyLlH95VM0hyw/JI7dLKmAwJlImHQcRTRbGy75PzxRjmwJXIKjFk/JEJk5TVv5tvPwgpChOJRlFsz8ou+ldBgGE7OayvZsxMRMTvB4mvYu7mMqqC6gWIDIO0bTp6F27hhYmD8VgRC8GSIF+Ex9zg== X-YMail-OSG: ghh6bjQVM1k.F_fvPmYdB6t7WKLVSygrp5GyNZzGKU0wfra57jzAHk5s0wzx8pV pdoBxWMg.aL9xXitzUU1ByKs8QGoCahIpDHGFAGOdtu40TCJn78MsE8ZxUVT7cbH4GKFflzoqUEA NCW9PJjIIehKlY7DNxU_LGR2x2VjBA0BoYAcdvs0cIUGIyzFNAqVnhg8niek.QgA9VflljWa3XRa CH_t37Iie_9jtGNhnhQ85XzhwJj8YS0E57JBPpTboVcXwSygXXYSKuSAtjDWkxRSbaNnECCVLOrt .ivGhw_kltyiGx1ttsTWkFH0NiRNiU2XrdWFMSNO0lq8ZZzG9bbeJ8pt5t2rHKnJxHZItMd4_KHJ 3f3KvBkurj7NZOEWwGUhzACPqUNJ6LuUw2MPwtHXns2_GtAjXfsiYIr0AeEW.TW6.4bfKQ8L5pKe M1FAhQ2zAPmbJ3rtSwApdGff1hatVyBUoG3xN3BhyaVoFDv9Jk.PepjqF1ft4KU_zIjjqgDhUXbo icNtjJGezFauno3Uy3SUpBEuGTvNKVuSx0r2QvHTYjrRFCLj.inPQZA2AkxeaeQ4K8NFVx6c3vUy 2pbCo1MFTKm7V.kc6HbHuF5GrNsoaRMS4oCi_sjc.n9w9GlDR5d_K0KgPQIxL47H5VR97aNahWG4 lyCndwbSkYxak1ul5OTttfM2L0YJdrHDBprP4zNRGGVzgA8HTrzVhAOi27fmnD2ctyEudiOTenck YrXmTlNvgDB9ou20Wwki29ybJ.EgpKiQFMf.3qkDtlqXNT9bsa1SOkpC0795V9WJ_BocCPG_rwaL 6hG9MbaNQMexKfUJmc.LW8KEya0j3J2vn6svAU8awH X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic302.consmr.mail.ir2.yahoo.com with HTTP; Sun, 6 Nov 2022 11:05:10 +0000 Original-Received: by hermes--production-ir2-74cf6dc4df-hf6d4 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID c4d6b6348f55e35687312bbe63e6d67e; Sun, 06 Nov 2022 11:05:08 +0000 (UTC) Content-Language: en-GB, es-CO X-Mailer: WebService/1.1.20826 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=87.248.110.83; envelope-from=ruben10post@yahoo.de; helo=sonic302-20.consmr.mail.ir2.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: "help-gnu-emacs" Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:140716 Archived-At: Hi all: I want to build a list of command-line arguments to run a program. Each element of the list must be a string. The commands are complex shell invocations with nested shell commands. I have been shell-quoting and concatenating plain strings for a long time, but it is error prone (in my experience). So now I am testing a different approach: I am building a list of strings, joining them with (string-join my-cmd-args " "), and passing the result to 'compile'. For nested commands, I use instead (shell-quote-argument (string-join my-sub-cmd-args " ")), and then append the resulting string to the parent command's list of arguments. And so on. When building a single command, there are optional, complex lists of arguments that get built somewhere else. So the code is building and concatenating many lists. This is the idea (very simplified): (setq cmd-args (list "arg 1" "arg 2")) (setq whole-cmd (append "cmd-exe" cmd-args)) However, I got into trouble with 'append'. Its documentation states: "Each argument may be a list, vector or string." I tested it like this: (append "1") -> "1" (append "1" "2") -> (49 . "2") That behaviour is surprising and it does not fit the bill. I need a routine like this: (my-append "1" (list "2" "3") "4" ) The result should be: ("1" "2" "3" "4") As a bonus, 'my-append' should check that all elements are strings, or list of strings (no nested lists, and no other data types). The trouble is, my Lisp skills are rather limited. Can somebody help? Thanks in advance, rdiez