tmp
Create a temporary file and write to it
tmp
creates a temporary file, writes the contents of
stdin to it then returns its filename to stdout.
You can optionally specify a file extension, for example if the
temporary file needs to be read by open
or an editor which
uses extensions to define syntax highlighting.
<stdin> -> tmp [ file-extension ] -> <stdout>
» out "Hello, world!" -> set tmp
» out $tmp
/var/folders/3t/267q_b0j27d29bnf6pf7m7vm0000gn/T/murex838290600/8ec6936c1ac1c347bf85675eab4a0877-13893
» open $tmp
Hello, world!
The temporary file name is a base64 encoded md5 hash of the time plus Murex function ID with Murex process ID appended:
package io
import (
"crypto/md5"
"encoding/hex"
"io"
"os"
"strconv"
"time"
"github.com/lmorg/murex/lang"
"github.com/lmorg/murex/lang/types"
"github.com/lmorg/murex/utils/consts"
)
func init() {
.DefineMethod("tmp", cmdTempFile, types.Any, types.String)
lang}
func cmdTempFile(p *lang.Process) error {
.Stdout.SetDataType(types.String)
p
, _ := p.Parameters.String(0)
extif ext != "" {
= "." + ext
ext }
:= time.Now().String() + ":" + strconv.Itoa(int(p.Id))
fileId
:= md5.New()
h , err := h.Write([]byte(fileId))
_if err != nil {
return err
}
:= consts.TempDir + hex.EncodeToString(h.Sum(nil)) + "-" + strconv.Itoa(os.Getpid()) + ext
name
, err := os.Create(name)
fileif err != nil {
return err
}
defer file.Close()
, err = io.Copy(file, p.Stdin)
_if err != nil {
return err
}
, err = p.Stdout.Write([]byte(name))
_return err
}
This should should provide enough distance to run tmp
in
parallel….should you ever want to.
tmp
files are also located inside a unique per-process
Murex temp directory which itself is located in the appropriate temp
directory for the host OS (eg $TMPDIR
on macOS).
tmp
pipe
: Manage Murex named pipesopen
: Open
a file with a preferred handler>>
: Writes stdin to disk - appending contents if
file already exists>
: Writes stdin to disk - overwriting contents if
file already existsThis document was generated from builtins/core/io/tmp_doc.yaml.
This site's content is rebuilt automatically from murex's source code after each merge to the master
branch. Downloadable murex binaries are also built with the website.
Last built on Sat Aug 23 22:28:13 UTC 2025 against commit ad23f13ad23f131bfecd82ea8a12d9b3e92aab5d8398ae9.
Current version is 7.0.2129 (website) which has been verified against tests cases.