Yes. It gave me quite a lot of trouble when I asked it to replace "cut -d:" with pure elisp. Eventually after a few minutes I got it to work, but during real work I probably would have just written it myself if something so simple didn't work the first time I asked.

Here's the log:

ChatGPT> Replace the cut shell command with a pure elisp implementation in this code:

(let* ((group-command "cut -d: -f1 /etc/group") ; command to list the groups
(group-data (with-temp-buffer
(shell-command group-command (current-buffer))
(sort (split-string (buffer-substring-no-properties (point-min) (point-max)) "\n") #'string<))))
(message "Selected group: %s" (completing-read "Choose a group: " group-data nil t)))
<shell-maker-end-of-prompt>
(let* ((group-command "cut -d: -f1 /etc/group") ; command to list the groups
(group-data (sort (split-string (with-output-to-string
(call-process-shell-command group-command nil standard-output))
"\n")
#'string<)))
(message "Selected group: %s" (completing-read "Choose a group: " group-data nil t)))

ChatGPT> replace group-command with and call-process-shell-command with elisp that does the same
<shell-maker-end-of-prompt>
(setq group-command "cut -d: -f1 /etc/group")
(setq group-data (sort (split-string (shell-command-to-string group-command) "\n") #'string<))
(message "Selected group: %s" (completing-read "Choose a group: " group-data nil t)))

ChatGPT> What is the elisp equivalent of: cut -d: -f1 /etc/group
<shell-maker-end-of-prompt>
The equivalent Elisp code for `cut -d: -f1 /etc/group` is:

(concat
(nth 0 (split-string (with-temp-buffer
(insert-file-contents "/etc/group")
(buffer-string))
"\n"))
":")

ChatGPT> Give me elisp I can evaluate to check that the elisp you gave is equal to the cut call
<shell-maker-end-of-prompt>
You can evaluate the following Elisp code to check that the Elisp I provided is equal to the `cut` call:

(equal
(concat
(nth 0 (split-string (with-temp-buffer
(insert-file-contents "/etc/group")
(buffer-string))
"\n"))
":")
(shell-command-to-string "cut -d: -f1 /etc/group"))

ChatGPT> It's not equal. the cut shell command gave a list of results. The elisp you gave only gives one result
<shell-maker-end-of-prompt>
I apologize for the confusion. You're right, the Elisp code I provided only returns the first entry in `/etc/group`.

Here's the updated code to get all group names from `/etc/group` file separated by a newline:

(with-temp-buffer
(insert-file-contents "/etc/group")
(let ((groups (split-string (buffer-substring-no-properties (point-min) (point-max)) "\n")))
(mapconcat #'(lambda (group)
(car (split-string group ":")))
groups
"\n")))

When you evaluate this Elisp code, it will return all the group names separated by a newline character, as the `cut -d: -f1 /etc/group` command would.

ChatGPT> Give me elisp to check the equality of it
<shell-maker-end-of-prompt>
You can use the following Elisp code to check the equality of the two commands:

(equal
(with-temp-buffer
(insert-file-contents "/etc/group")
(let ((groups (split-string (buffer-substring-no-properties (point-min) (point-max)) "\n")))
(mapconcat #'(lambda (group)
(car (split-string group ":")))
groups
"\n")))
(shell-command-to-string "cut -d: -f1 /etc/group"))