From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/33306 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: BPJ Newsgroups: gmane.text.pandoc Subject: Re: Better way to get default datadir Date: Sun, 12 Nov 2023 11:09:18 +0100 Message-ID: References: <87edgxwulq.fsf@zeitkraut.de> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000090c7ed0609f1bf1d" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12614"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCWMVYEK54FRBV6IYKVAMGQEBML3FEY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sun Nov 12 11:09:31 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-il1-f185.google.com ([209.85.166.185]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1r27PH-00036d-8b for gtp-pandoc-discuss@m.gmane-mx.org; Sun, 12 Nov 2023 11:09:31 +0100 Original-Received: by mail-il1-f185.google.com with SMTP id e9e14a558f8ab-357429e8ac0sf32560055ab.1 for ; Sun, 12 Nov 2023 02:09:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699783770; cv=pass; d=google.com; s=arc-20160816; b=V2NuWt9Y/JMGX3+jhOCkBlDG/vDuOk1BvLAzZ7zUbESVbF22F1kVw9+TbQzZl0sfNA wa0gKSdNTQJA2af0Y4MtyVeBJvZJYDbU5QKTZB/lJeZxwHf6611OKiKVbJhLCxnqHKVw AyhSikVhcw6US688vVDVy6pHBG8N+sGLYCNr8ipkNB+WoLl4rUVR5pePld7BKCvq4p4E VtHcAntNOd1FkS/vKn0qoXWwK/f+5vSbBKKYD8aGqGxwpZu414Z02xLlTKW3k6TJ0s7+ Jtu8rtQ+HALiO6weQ8gCS8fNuS/whSoD/9Sgv/P3lR1EYoC2yLsHrcqcIkRiBGiS7gyV 2olw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:to:subject:message-id:date :from:in-reply-to:references:mime-version:sender:dkim-signature :dkim-signature; bh=sW7mztoIrfn1dgAAK2Oi2ogMiO2uwFreGPEMGKXOvBc=; fh=4cPfTtzleA5nPUC1EQtk197aIUeaT1ew1v/oILbLT2I=; b=Qj4sco1QT4rFGMkWw8WfCeYAqTET36wga6yPQGrU3O6VgCuKjnrBTTOSpgaCDB3mC5 4yTgq0NkFzzLPNU6CNNI5jok2xmHuHOHpmL7GWeDbjZwnX/My5u9g7Gjl0Y1eJGmjeU5 jc9bVZiKr/Fzy1ja7wxk8DYbumhP6uIXzKe0RGF5xcq0JNmv3O1ryZ8DIYra4mz5SivU d87k0Imm61u+Ar5Pe6cPZkRkRYQiL0eFqMTpQjldvERZVly5IuPLeOYhIXdiiPMjPhoO nSg0YdMFUaVKSI0wXg+k2QhYRYFYuBgsQ5KX4qwZW4UhYC+2hE6tr9cTwg8mIjnl+esB 9ZFw== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=SBR67LUX; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::b35 as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1699783770; x=1700388570; darn=m.gmane-mx.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:to:subject :message-id:date:from:in-reply-to:references:mime-version:sender :from:to:cc:subject:date:message-id:reply-to; bh=sW7mztoIrfn1dgAAK2Oi2ogMiO2uwFreGPEMGKXOvBc=; b=v+lWt/FwkHsjtR0/0v6vMwFh8n/cg5wSVGwyMJi12NWZWBEFCZofSeEDqGIgZQBlY2 5XjLn3B+7rGu63cTeeWfjTa/3nAyfVwNMzEblJltuaUk1JmrgGwubX6dP3Zww2a4uO1a Ugd8Ogvnytzx+un9edNgZshZ7u5dMX9v3VTo+2ICq5BKTykOaTO3ZCQWXnF7KQGwIxCa H2RuOUb39lBpjXN5dV+jgrJF2OMUpTQ84sehCKJJ3SxZjtUsKGtND64xXUEwNOVtCKjB BAOQNwCtRD2F+bxRh3LznLPU6p4y+MkB2v2LUtAcMaZ6v7dEMDaF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699783770; x=1700388570; darn=m.gmane-mx.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:to:subject :message-id:date:from:in-reply-to:references:mime-version:from:to:cc :subject:date:message-id:reply-to; bh=sW7mztoIrfn1dgAAK2Oi2ogMiO2uwFreGPEMGKXOvBc=; b=A3wocIiTr8PoZSUDYiNIAJhdosovuHQVejHZARStdkcpynrUdwZMO3guv/x31KTqql CECVMdPAT0KJ4WB3snabC3biJ8Yz4Rkd7eKO+Sn3a+aOBzEnLRFj9P/icMSUP2bv5wsd GxZyVvEhHvIyIMVIRfsqtHcSnQ/M177VyDJXBlnjZho2lgQKNrmbBFTQU6psYBkcR5tK 5A6REC26wyr43WqyT75OwqwirpEY9Gmshfa8SOc6/nxfkFtNuZBylzOvdfBclsYs0nPW L/RsGdv5rlUAS7LMyYGwGPtboisTnWIrV9vnG+7qvey4fwRrd1oi0o/EwkvWjbnW8b X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699783770; x=1700388570; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:to:subject :message-id:date:from:in-reply-to:references:mime-version :x-beenthere:x-gm-message-state:sender:from:to:cc:subject:date :message-id:reply-to; bh=sW7mztoIrfn1dgAAK2Oi2ogMiO2uwFreGPEMGKXOvBc=; b=gN/MRFpHiQSZggE2MBvC2Pg8TVEqnjNqHfy7mhC64vmEFyRo0vOo1seK7osIur8m8H 0RnGme2tkFDQfouR42UptV1BNV4h7dUhKlLeAG25EC6s35Kan0untRLZa/BZhEjwgy3Q jS6py0ohYPWE4no0S4RF/045MpoIdvwkqYekD6o5NDTEIw3ZF2D1gNO+Ji8I/pX9J4Ti D1TgWCZurG8frIR6MVeS5fFHFhUS3cUdDm7eMDrNIVfRofD92bgH5xADz2CcHkgldk4V 5vLzWy Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOJu0YxH5iG6+ZyTkVculabJS4QlXw2SHowQC90V9hG1g5SDlwyYkk9s Pbim6oCUJbllDGir8q3P26c= X-Google-Smtp-Source: AGHT+IHS2UyMgwnJGlB+QxoUPcKtzomcRDTrAqMOVQCrAQUTNU3qMt3UDRq1SdcLm3kKoRzelZMdBA== X-Received: by 2002:a05:6e02:1d8b:b0:359:4ae3:cd8d with SMTP id h11-20020a056e021d8b00b003594ae3cd8dmr6265331ila.6.1699783770083; Sun, 12 Nov 2023 02:09:30 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a92:870a:0:b0:357:3d9d:209e with SMTP id m10-20020a92870a000000b003573d9d209els188862ild.2.-pod-prod-06-us; Sun, 12 Nov 2023 02:09:26 -0800 (PST) X-Received: by 2002:a05:6e02:1545:b0:359:4b3b:530d with SMTP id j5-20020a056e02154500b003594b3b530dmr5651687ilu.7.1699783766632; Sun, 12 Nov 2023 02:09:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699783766; cv=none; d=google.com; s=arc-20160816; b=rZOE1L+EdW+okGx8VmM+rssTrIBiHpeq5IrnUZNIGIPIiiY38awr74fSp2I9Xpf+d3 2PZTq9ZdDdyIjWWTPTMsfVSdoNSdsGsHjNXYs5H4OHWyWY3oHKnN63qdOE/RRCVY9BQq 4ZZXS9yitKeWptmn8PPwgb50VWirxM5jhNyGsQ9es+IK1BEtodXCYHtyExxaDNgNr/I7 5uAel3QiLHMQzaDOpw1eYxi8WBbwrMjH1DKg2cOqnBgrc8NC1oAQLauyfbeZ1jTqWyxo YrG0m4qUhsIL+taBznUdMWK2bpgaqj+53K+ohGoOc0QbUzWGq4aAhEO8GT4rd4Ai3wG8 XzDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=a8xU4PCTeEdct6XvkUVy23MshFuWSpfKRzM8imSIfZI=; fh=4cPfTtzleA5nPUC1EQtk197aIUeaT1ew1v/oILbLT2I=; b=ARaOih/pocqSgCwxq/qchfRheGtdZ/CJ8UP27+nd7wU3h1aLJL2NkIWwtQvUXJ2rIp puxCOWTaymdafrEDKBdkxJ3g1OY34L92Kjhl8/vg/3cb1YqLGv0sASykPqdBDMtcLKCN 83nLitbbi+Ifci4sX0ZEBSPqiRUttTFOTHMn8QSEdL08tko/vrTSwENJMkZiyb4W9WK3 BULgqVX8yZmRu0pUx8ZcVAm9sw7tDxfFy4dbUaUbhb4JgK77c1pZeroVKmbxC65MGzY/ a7Fk/lBWrKw35zneUJeQM9BXAxXJSonXB1j+YTXhkDsNyIDTPn8+A1BGBS6rLP4hHaZZ gobQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=SBR67LUX; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::b35 as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Original-Received: from mail-yb1-xb35.google.com (mail-yb1-xb35.google.com. [2607:f8b0:4864:20::b35]) by gmr-mx.google.com with ESMTPS id bn10-20020a056e02338a00b0035ab2f0d294si165717ilb.2.2023.11.12.02.09.26 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 12 Nov 2023 02:09:26 -0800 (PST) Received-SPF: pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::b35 as permitted sender) client-ip=2607:f8b0:4864:20::b35; Original-Received: by mail-yb1-xb35.google.com with SMTP id 3f1490d57ef6-dae0ab8ac3eso3407277276.0 for ; Sun, 12 Nov 2023 02:09:26 -0800 (PST) X-Received: by 2002:a25:d3c6:0:b0:da3:b87b:5b72 with SMTP id e189-20020a25d3c6000000b00da3b87b5b72mr2593065ybf.44.1699783765967; Sun, 12 Nov 2023 02:09:25 -0800 (PST) In-Reply-To: <87edgxwulq.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org> X-Original-Sender: melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=SBR67LUX; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::b35 as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.io gmane.text.pandoc:33306 Archived-At: --00000000000090c7ed0609f1bf1d Content-Type: text/plain; charset="UTF-8" I have for some time had an environment variable PDC_DATA_DIR with the absolute path to the data directory as value. It is convenient to use both in filters and scripts and to navigate in the shell, and I can use it inside Vim as well. Den fre 10 nov. 2023 15:29Albert Krewinkel skrev: > > DG writes: > > > I have a script installs templates and default files on multiple > platforms. > > > > In order to get the default datadir I use sed : > > > > pandoc -v | sed -rn "s/User data directory: (.*)$/\1/p" > > > > It works, but it is (a) not very elegant and (b) it depends on sed and > > might fail on windows. My question is: What am I missing? Is there a > > more direct way to get the default datadir? > > First, here's a way that DOESN'T work, but maybe it should? > > pandoc lua -e 'print(PANDOC_STATE.user_data_dir)' > > This only prints `nil`, because the value is not set when pandoc is > called as a Lua interpreter. But it could be argued that the default > data dir should be returned if it exists. > > The alternative is to use a single-line file > > print(PANDOC_STATE.user_data_dir) > > and to pass it to pandoc as a Lua filter, e.g. > > echo "" | pandoc -L datadir.lua > > Some shells support "process substitution". In those cases we can write > a one liner > > echo "" | pandoc -L <(echo 'print(PANDOC_STATE.user_data_dir)') > > or even just > > pandoc -L <(echo 'print(PANDOC_STATE.user_data_dir)') <<< '' > > But that's not portable. > > > Feel free to raise an issue on the bug tracker to get future support for > the potentially simpler version mentioned above. > > > -- > Albert Krewinkel > GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124 > > -- > You received this message because you are subscribed to the Google Groups > "pandoc-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msgid/pandoc-discuss/87edgxwulq.fsf%40zeitkraut.de > . > -- You received this message because you are subscribed to the Google Groups "pandoc-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhB%3D77D0kDWK8-JRRQKRZUAHO2%2BF%3D%2B8WuG-B0JhXKOy9UA%40mail.gmail.com. --00000000000090c7ed0609f1bf1d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I have for some time had an environment variable PDC_DATA= _DIR with the absolute path to the data directory as value. It is convenien= t to use both in filters and scripts and to navigate in the shell, and I ca= n use it inside Vim as well.

Den fre 10 nov. 2023 15:29Albert Krewinkel &l= t;albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org> skrev:

DG <dominik.gerstorfer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
> I have a script installs templates and default files on multiple platf= orms.
>
> In order to get the default datadir I use sed :
>
> pandoc -v | sed -rn "s/User data directory: (.*)$/\1/p"
>
> It works, but it is (a) not very elegant and (b) it depends on sed and=
> might fail on windows. My question is: What am I missing? Is there a > more direct way to get the default datadir?

First, here's a way that DOESN'T work, but maybe it should?

=C2=A0 =C2=A0 pandoc lua -e 'print(PANDOC_STATE.user_data_dir)'

This only prints `nil`, because the value is not set when pandoc is
called as a Lua interpreter. But it could be argued that the default
data dir should be returned if it exists.

The alternative is to use a single-line file

=C2=A0 =C2=A0 print(PANDOC_STATE.user_data_dir)

and to pass it to pandoc as a Lua filter, e.g.

=C2=A0 =C2=A0 echo "" | pandoc -L datadir.lua

Some shells support "process substitution". In those cases we can= write
a one liner

=C2=A0 =C2=A0 echo "" | pandoc -L <(echo 'print(PANDOC_STA= TE.user_data_dir)')

or even just

=C2=A0 =C2=A0 pandoc -L <(echo 'print(PANDOC_STATE.user_data_dir)= 9;) <<< ''

But that's not portable.


Feel free to raise an issue on the bug tracker to get future support for the potentially simpler version mentioned above.


--
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe=C2=A0 e836 388d c0b2 1f63 1124

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pandoc-discuss+unsubscribe@go= oglegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/= pandoc-discuss/87edgxwulq.fsf%40zeitkraut.de.

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pand= oc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https:/= /groups.google.com/d/msgid/pandoc-discuss/CADAJKhB%3D77D0kDWK8-JRRQKRZUAHO2= %2BF%3D%2B8WuG-B0JhXKOy9UA%40mail.gmail.com.
--00000000000090c7ed0609f1bf1d--