Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
ZQL – a language for *declaring* scripts content. Any ideas for changes maybe?
- X-seq: zsh-users 24085
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: ZQL – a language for *declaring* scripts content. Any ideas for changes maybe?
- Date: Mon, 22 Jul 2019 18:27:41 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=r9qnLRPElSF9IPnLptoKG4IuZbS1VwaTPZHin7D+bXU=; b=VJKoyJQcauf7pLwtaPmLt6eOVQvom+qZQ7Q/lYkNDv5fQhpYh+TYefLKNCpOqMq04X ns4L5lPNQxNzCoaWzvaOI5eEtoamIHU9KXEgrdgpoSpLShfMteEh3o7hMFjmxwYMTOl/ ZNwj+KFAMc96SsZzaB37xABN4e+uyW17b/v54j8P/yVYwB+ajsQvLVGsXVYATEUn8vKI Tz6eciQPSq5NaiwVzfVn0Q+chhOxoXHWq8dzV1tw90YqlaqQDcWtMwlSkrnA4RavLr4l ZRG6CJcSLca3kKyxvavLc+weZwdKo5BsjVko2ulw37BhOOaX6EU0UNjAElTPBhqPNjfc Vpyw==
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
Hello,
when I once tried NixOS, a system with declarative configuration at
its core, i was naively expecting that I'll be able to declare zshrc.
So, for example, that I'll be able to write some kind of rule "append
command {X} to the end of the zshrc if it's not somewhere in the
file". Turned out that those expectations were way out of the scale,
as what was actually possible was to fill 3 configuration fields with
the text of the zshenv, zprofile and zshrc.
ZQL is to implement the feature. Example code:
PRE { setopt #; print "**"; ls $ }
ALTER { echo * "added" }
POST { VALUE=* }
1. PRE and POST are the contextual surroundings of the inner code that
does the editing.
2. The `setopt #` says: match setopt command that takes string.
3. So # denotes string. It doesn't matter if it's given as "#" or '#'
or # – it will match all three kinds of strings (unquoted, " and '
plus also $'').
4. Now, if instead of single # there will be two ##, then this is
quotation-locked matching – it matches strings with only the kind of
quoting that's used for symbol. So, for example, '##' will match only
'string'.
5. # matches strings but not variables
6. To match also variables, there's the * symbol, with the same
quotation-locking features.
7. To match variables, there's $ symbol (with the $$ counterpart as well).
So, basically, the command matches a context of three preceding
commands setopt, print and ls and one trailing command – an assignment
VALUE={anything}. After this, it then applies the middle editing block
ALTER wchi;
1. Leaves 1st echo argument untouched (because it has * assigned)
2. Sets second argument to "added"
This is how I imagine ZQL and the true declaring of zshrc contents.
For more information you can take a look at the project's wiki:
https://github.com/zdharma/declare-zsh/wiki/ZQL-draft
Are there any easily detectable flaws in the idea? What else could be
added to the language?
The project has fairly sophisticated parsing already implemented.
Currently, it allows to disable / enable zplugin's commands (that's
how the project started; I'm thinking about exposing a plugin
interface for other commands that might benefit from such
highly-targeted approach) by providing a plugin name / pattern
matching it.
--
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org
Messages sorted by:
Reverse Date,
Date,
Thread,
Author