From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Hongyi Zhao Newsgroups: gmane.emacs.help Subject: Re: Start Emacs with a minimal bash and Emacs lisp mixed script for testing. Date: Wed, 4 Aug 2021 08:26:56 +0800 Message-ID: References: <87y29ijzfg.fsf@zoho.eu> <87tuk6jysk.fsf@zoho.eu> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37914"; mail-complaints-to="usenet@ciao.gmane.io" To: Emanuel Berg , help-gnu-emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Aug 04 02:27:41 2021 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 1mB4l3-0009hB-DG for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 04 Aug 2021 02:27:41 +0200 Original-Received: from localhost ([::1]:37926 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mB4l1-0003rS-V5 for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 03 Aug 2021 20:27:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50762) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mB4ka-0003rJ-Od for help-gnu-emacs@gnu.org; Tue, 03 Aug 2021 20:27:12 -0400 Original-Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]:34321) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mB4kZ-0003No-1B for help-gnu-emacs@gnu.org; Tue, 03 Aug 2021 20:27:12 -0400 Original-Received: by mail-lj1-x236.google.com with SMTP id m18so637127ljo.1 for ; Tue, 03 Aug 2021 17:27:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=NmohMSA+/oMmkEFaylacO7FkJ+HwR8zS0jdv9Khj9Tw=; b=qxrD9xBrqXoRRpCDQUbBhCejNSdrinrrgpIiTniGAwS7DONJysxrDqRVqywRzm0bUX ewYtwzozRwXz2Icm5NoO29W9RnEPvVo8KheRT1OHVFaqti/eS7u6/hmtFAnJD65o08gw ZgsE6I4Hckf4HKQNZ2mOCb8v73DJcUUGJbNQ3w6B2VL+ncjpOWgG9RAxvTtczM9GfEsA orTFdMoebT0BILxeudC9Tw9+fL1IXS/6E4mh6ai7OWzU3sKIvsh2rVeDY0QpIjCjP/3Y OeAli/BcYUQoTpkAPNk9tIf9fDaUcs8aSsA2GIkAnS4fjTUXyAs367msII5tIzeplJ+K o2dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=NmohMSA+/oMmkEFaylacO7FkJ+HwR8zS0jdv9Khj9Tw=; b=TKW72JQp03U6LNqNZLvMNMjkM12MNz2Rht6rglq8F9q6ZrClvqNV7P1XFrcW6jwSlm eKtVRi780JjSQmyRYzgR1J3OMUeboYpCVpXVmVDh3wo4xABmBpEI2O4BAn36yUrVcbVL ieLy6XAgPrVaTF0OMWWB5kNRk2H8llIOwx5wugNe97bTcwEYRS7xs4zURbyFF5z3kSma lm9wHmJPFWKhqwLp1YI5LqnGfgFYAt6jC+5Zzd9m3PoZCNNf3k9su37ZuwS0Rf+jez4+ ahADF7P2TiysqwlxsxJTBgzyXX5ZRtZOg1WF+PD3CyoEzPq+K+ykchsRIk6Y6bO2SC7V 82GA== X-Gm-Message-State: AOAM5316N9cZ+UmNmrwb5QTrBS9Z5WgvfXPa4kIL6EaRYtObZutX4PxW 3/5NfmF7XX5bORUPb9Sj66Tiz4bHbeRavlTqa1Y= X-Google-Smtp-Source: ABdhPJwUPUlPvdMPehdrXpT28u4WRxUQTNqmkurPvFzxoVQY2MaGEdes8htwCuPExmJJwdjByuXPnERkPPsqdiyofvg= X-Received: by 2002:a2e:bd0c:: with SMTP id n12mr16123744ljq.447.1628036828567; Tue, 03 Aug 2021 17:27:08 -0700 (PDT) In-Reply-To: <87tuk6jysk.fsf@zoho.eu> Received-SPF: pass client-ip=2a00:1450:4864:20::236; envelope-from=hongyi.zhao@gmail.com; helo=mail-lj1-x236.google.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.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:132352 Archived-At: On Wed, Aug 4, 2021 at 12:09 AM Emanuel Berg via Users list for the GNU Emacs text editor wrote: > > > Try: > > > > #! /bin/bash > > > > :; set -e > > :; emacs -Q --load "$(realpath -e $0)" -- "$@"; exit > > > > (setq test-var 3) > > > > Then type test-var and do `eval-last-sexp'. > > Or even more minimal: > > #! /bin/zsh > > ; emacs -Q --load "$(realpath -e $0)"; exit Wonderful. The key point is the `exit' command used here, which will fix the error I encountered. After I posted this email, I found another similar usage [1], which is exactly the trick you suggested above. Another question: how to do the same job with the `--script' option of Emacs? I've tried with the following command, but failed to start Emacs: :; emacs -Q --script $(realpath -e $0); exit [1] https://github.com/alphapapa/matrix-client.el/blob/d2ac55293c96d4c95971ed8e2a3f6f354565c5ed/matrix-client-standalone.el.sh#L64-L81 > (setq test-var 1) > > (I changed the shell to zsh because that's what I use.) > > And you don't have to do 'bash SCRIPT', instead just > 'chmod +x SCRIPT', put in $PATH, and 'SCRIPT'. Thank you for your suggestion. Best regards -- Assoc. Prof. Hongyi Zhao Theory and Simulation of Materials Hebei Vocational University of Technology and Engineering No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province